Reputation: 71
I have a list of zip codes to loop over to get the lat/lng. How do I pass the object zip to the "success" method so I can assign the lat/lng to the right zip object? Right now by the time I get the results back, I assign them to the wrong zip :-(
I believe the response is the dataContext object but when I tried { zip : zip }, it didn't work. The response contains no such property.
for (var j = 0; j < zipList.length; j++) {
var zip = zipList[j];
L.esri.Geocoding.geocode().postal(zip.Zipcode).run(function (err, results, response) {
alert(response.zip);
}, { zip : zip });
}
Upvotes: 0
Views: 34
Reputation: 47
As per my understanding the code used to fetch geo location is running asynchronous. I would suggest you to first get all geo location using some waiting loop. Once you get all lat lon than use the forloop to update dB.
Upvotes: 0