Skip to content

Instantly share code, notes, and snippets.

@thinkt4nk
Created May 10, 2011 15:46
Show Gist options
  • Save thinkt4nk/964716 to your computer and use it in GitHub Desktop.
Save thinkt4nk/964716 to your computer and use it in GitHub Desktop.
Reverse Geocoding with Google js API
function ReverseGeocodeLatLng(latlng)
{
var geocoder = new google.maps.Geocoder();
if (latlng !== undefined) {
latlng = latlng.split(',');
var LatLng = new google.maps.LatLng(latlng[0],latlng[1]);
geocoder.geocode({location:LatLng},function(result,status) {
if( status == 'success' ) {
var locationString = "";
$(result).each(function() {
var $result = this;
if( $result.types.inArray('locality') && $result.types.inArray('political') ) {
locationString = $result.formatted_address;
}
});
return locationString;
}
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment