I am trying to retrieve multiple values from a for loop to be pass into the esri.Geocoding function, but the problem is it only returned the first value and repeat it according to the number of records instead of returning the next value and so on. Any help is appreciated, thank you.
for (var i = 0; i < planes.length; i++) {
var lat2 = planes[i][1];
var lon2 = planes[i][2];
var time2 = planes[i][0];
L.esri.Geocoding.reverseGeocode()
.latlng([lat2, lon2])
.run(function(error, result) {
if (error) {
return console.log("empty");
} else {
//markers.bindPopup("Time: " + time2 + "<br/>Location: " + result.address.Match_addr);
//markers.addTo(mymap);
alert(lat2 + ", " + lon);
}
});
}