RSS

Reverse Geocoding with Google Map API

13 May
Reverse Geocoding

Reverse Geocoding

Demo

If you know the latitude and longitude of a particular location, you can get the relevant address details such as city, state, region, country…etc. This process is known as Reverse Geocoding. In this post I ‘m gonna show you how this could be achieved with famous Google Map API. This entire post is based on one API request. Look at below code.

http://maps.googleapis.com/maps/api/geocode/json?latlng=-37.814251,144.963169&sensor=false

Enter above line in the browser bar to see a whole bunch of location details for the geographical point (-37.814251,144.963169) in lat lng format.
Pretty Simple. Here I’m using Google Map JavaScript API V3. All you need to do is to parse the json response to extract the information whatever you need.

jQuery.ajax({
url: 'http://maps.googleapis.com/maps/api/geocode/json?latlng=-37.814251,144.963169&sensor=false',
type: 'POST',
dataType: 'json',
success: function(data) {
if(data.status == 'OK')
{

alert(data.results[1].formatted_address);
alert(data.results[1].address_components[0].long_name);
alert(data.results[1].address_components[1].long_name);

}

},
error: function(xhr, textStatus, errorThrown) {
alert("Unable to resolve your location");

}
});
Advertisements
 
2 Comments

Posted by on May 13, 2013 in Geo Programming, JavaScript

 

Tags: ,

2 responses to “Reverse Geocoding with Google Map API

  1. scrapebox lists

    June 4, 2013 at 5:59 pm

    finally i found someone who knows how to provide relevant information on the subject i have been searching for? thanks, at last i can study with pleasure..

     
  2. nordstrom cocktail dresses

    June 12, 2013 at 3:50 pm

    Good day. Very cool blog!! Guy .. Excellent .. Amazing .. I will bookmark your site and take the feeds additionally…I am glad to find a lot of useful info right here in the post. Thank you for sharing…

     

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: