Created
May 10, 2011 15:46
-
-
Save thinkt4nk/964716 to your computer and use it in GitHub Desktop.
Reverse Geocoding with Google js API
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 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