I've seen a few jscript/jquery implementations of this concept in reverse, where you can enter a zip code and get a long/lat from the google maps api.
However, in my case, I already have a set of coordinates and was wondering if its possible to dynamically get a textual City, State result from the API when we feed it the long/latitude via jquery?
Thanks!
This is a process called reverse geocoding, and Google have quite extensive documentation on it.
An example would be:
$.ajax({ url:'http://maps.googleapis.com/maps/api/geocode/json?latlng=40.714224,-73.961452&sensor=true',
success: function(data){
alert(data.results[0].formatted_address);
/*or you could iterate the components for only the city and state*/
}
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With