0
var addressArr = new Array();
....
for(var i=0;i<addressArr.length;i++){
      geocoder_map.geocode( { 'address': addressArr[i]}, function(results, status) {

        alert(addressArr[i]); // here i found undefined - how i will find this value here ?

      });
}

我尝试过在隐藏字段中查找值,也喜欢..

 var addressArr = new Array();
    ....
 document.getElementById("hidAddressStr").value = addressArr[i];
    for(var i=0;i<addressArr.length;i++){
          geocoder_map.geocode( { 'address': addressArr[i]}, function(results, status) {

            alert(document.getElementById("hidAddressStr").value); // i found only single value from here

          });
}
4

1 回答 1

0

尝试使用单独的功能

var testFunction = function(str) {
    geocoder_map.geocode( { 'address': str}, function(results, status) {
        alert(str);
    });
}

for(var i=0;i<addressArr.length;i++){
    testFunction(addressArr[i]);
}
于 2013-04-04T12:05:50.930 回答