When it comes to geocoding, I rely on
http://tile.cloudmade.com/wml/latest/web-maps-lite.js
.
I have an array filled with approximately 20 addresses.
addresses[n] = {where:where,who:who,contact:contact,note:note,type:type};
My process involves looping through this array for geocoding purposes.
for (var i = 0; i < addresses.length; i++) {
geocoder2.getLocations(addresses[i].where, function(response) { //a callback
return function(k){
Lat[k] = response.features[0].centroid.coordinates[0];
Lng[k] = response.features[0].centroid.coordinates[1];
latlng = new google.maps.LatLng(Lat[k], Lng[k]);
MarkerArray[k] = new google.maps.Marker({
map: map,
position: latlng,
zIndex: k,
title: addresses[k].who,
icon: icons(addresses[k].type.trim())
});}(i) // a closure function called
});
}
Despite the setup, I keep encountering an issue where it only works on the final index. Why could that be?