我一直在搜索 stackoverflow 和网络的其余部分无济于事。我是一名新手程序员,我完全陷入了这个问题。
我有一个结构如下的数组:
地址A SuburbA 地址B SuburbB
当以下代码运行时,它会通过放置一个标记和围绕该标记的 10 英里圆圈来更新地图。问题是,当我将鼠标悬停在标记上时,工具提示/标题始终是 SuburbB 的,即使标记和圆圈位于正确的位置。
让我发疯,非常感谢您的帮助!
function codeAddress(){
var arrayLength = array.length;
var looper = 0;
var looper2 = 1;
while (looper < arrayLength) {
alert("Geocode started");
sAddress = array[looper];
alert (looper)
alert("Address set" + sAddress)
sName = array[looper2];
alert (looper2)
alert("Name set" + sName)
geocoder.geocode( {'address': sAddress}, function(results, status) {
alert("Make marker");
if (status == google.maps.GeocoderStatus.OK) {
map.setCenter (results[0].geometry.location);
var marker2 = new google.maps.Marker({
map: map,
title: sName,
position: results[0].geometry.location
});
var circle = new google.maps.Circle({
map: map,
radius: 16093, // 10 miles in metres
fillColor: '#AA0000',
strokeWeight: 2,
strokeOpacity: 0.5
});
circle.bindTo('center', marker2, 'position');
} else {
alert("Geocode was not successful for the following reason: " + status);
}
})
looper = looper + 2;
looper2 = looper2 + 2;
}
}