function initialize(final)
{
if (GBrowserIsCompatible()) {
................................................
}
var address_array = final.split('~');
for (var count = 0; count < address_array.length; count++) {
if (geocoder) {
geocoder.getLatLng(
address_array[count],
makeTheFunction(address_array, count)
);
}
}
}
function makeTheFunction(array, thisCount) {
return function (point) {
if (!point) {
alert(array[thisCount] + " not found");
}
else {
var marker = new GMarker(point);
map.addOverlay(marker);
GEvent.addListener(marker, "click", function() {
marker.openInfoWindowHtml(array[thisCount] + "</b>");
});
}
};
}
我的問題是謂我不是能從其他部分,雖然其可訪問從if塊訪問array[thisCount]
..即alert(array[thisCount] + " not found");
工作 請幫助關閉在JavaScript
你可以嘗試在else分支中放置一個警告 - 我懷疑應該工作正常,這意味着問題是addListener方法正在做什麼。 – Xhalent 2011-05-24 10:59:28