0
我一直在寻找stackoverflow和其他网络无济于事。我是一个新手程序员,我完全停留在这个问题上。Google Maps API标记循环没有正确更改标题
我已被构造为阵列如下:
地址a SuburbA AddressB 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;
}
}
谢谢,我想我明白了,我已经改变了它。但它仍然无法正常工作......我是否需要在某处传递sName以使其可用? – Tomn8r 2013-03-12 08:35:34