I’m working with google maps to geocode addresses for display on a map. I’m looping through each address and handling the response through a callback via jquery.
How can I identify which item the call back is from?
var geocoder = new google.maps.Geocoder();
geocoder.geocode({ 'address': addr }, function (results, status) {
if (status == google.maps.GeocoderStatus.OK) {
var marker = new google.maps.Marker({ position: results[0].geometry.location, map: map, title: "Yo Homie" });
// I need to find the item to setup the infowindow
bounds.extend(results[0].geometry.location);
map.fitBounds(bounds);
}
else {
// eat it like a mexican jumping bean
}
});
i wrap the geocoder call into a function, pass your object into that function then you can use it in the callback of geocoder as well.
example: