Created
May 12, 2012 08:15
-
-
Save w0rse/2665178 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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