【发布时间】:2013-07-04 04:49:45
【问题描述】:
我正在做一个带有地理编码的页面,它运行良好,但总是出现在谷歌地图中没有分类的地址数组中。不幸的是,地理编码器并没有什么都不做,而是将未找到地址的标记放在地图的中心。
有一些代码可以让地理编码器不放置这个未找到的标记?
(我是巴西人,我的英语不好,抱歉 =))
function addMarker(position) {
var geocoder;
geocoder = new google.maps.Geocoder();
geocoder.geocode({'address': address[position]}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
places[position] = results[0].geometry.location;
var marker = new google.maps.Marker({
position: places[position],
map: mapa,
icon: icone,
title: ('OS: ' + arOS[position] + ' - ' + arEndereco[position]),
url: 'OSDETALHES.asp?txtCodigoOS=' + arOS[position]
});
google.maps.event.addListener(marker, 'click', function() {
window.open(this.url, '_blank');
});
}
else
{
if (status == google.maps.GeocoderStatus.OVER_QUERY_LIMIT)
{
setTimeout(function() { addMarker(position); }, (timeout * 3));
}
}
address_position++;
if (address_position < address.length)
{
setTimeout(function() { addMarker(address_position); }, (timeout));
}
});
}
}
【问题讨论】:
-
您能否展示一下您用于向地图添加标记的代码?
-
这是填充标记的主要功能。我想要的是:当找不到地址时,不要放置标记。有可能吗?