Skip to content

Instantly share code, notes, and snippets.

@w0rse
Created May 12, 2012 08:15
Show Gist options
  • Save w0rse/2665178 to your computer and use it in GitHub Desktop.
Save w0rse/2665178 to your computer and use it in GitHub Desktop.
function make_geocode_handler(address) {
var retry_count = 0,
retry_timeout = 5000;
function geocode_handler(geoResult, status) {
if (status == google.maps.GeocoderStatus.OK) {
positions[keys[i]] = {'lat' : geoResult[0].geometry.location.lat(), 'lng' : geoResult[0].geometry.location.lng()};
d.resolve();
} else {
if (++retry_count < 5) {
setTimeout(function() {
geoCoder.geocode({'address': address}, geocode_handler);
}, retry_timeout);
} else {
$('#message').text('Geocode was not successful for the following reason: ' + status);
}
}
}
return geocode_handler;
}
geoCoder.geocode({'address': addresses[i]}, make_geocode_handler(addresses[i]));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment