Google Maps Reverse Geocoding API in PHP

Google Maps Reverse Geocoding API is the tool (web-service), which converts the given geo-coordinates (latitude , longitude) in to human readable format address like in the illustration below

13.0810 & 80.2740 ————> Poonamallee High Road, Park Town, Chennai, Tamil Nadu, India

(Geo-coordinates)                                (Human Readable format address)

Google Maps Reverse Geocoding API in php live Example

Reverse Geocoding Demo

Reverse Geocode Google Maps API in PHP

Reverse Geocode Google Maps API in PHP

So Google Maps Reverse Geocoding API is  a web service, which gives JSON or XML formatted output when you send input in right format  Here is URL of the Google Maps Reverse Geocoding API web service.

http://maps.googleapis.com/maps/api/geocode/json?latlng=40.714224,-73.961452&sensor=true_or_false

where

latlang – Latitude & Langitude value of location on maps for which we need human readable address.
sensor (true) – Indicates geocode request from device with sensor.
(note : sensor parameter must be true or false in the url while requesting result)

http://maps.googleapis.com/maps/api/geocode/json?latlng=13.0810,80.2740&sensor=true

Sample JSon output for the given latlng value (13.0810,80.2740).

“formatted_address” : “Poonamallee High Road, Park Town, Chennai, Tamil Nadu, India”,
“geometry” : {
“bounds” : {
“northeast” : {
“lat” : 13.08159910,
“lng” : 80.27514250
},
“southwest” : {
“lat” : 13.08136550,
“lng” : 80.27338689999999
}
},
“location” : {
“lat” : 13.08149240,
“lng” : 80.27426340
},
“location_type” : “APPROXIMATE”,
“viewport” : {
“northeast” : {
“lat” : 13.08283128029150,
“lng” : 80.27561368029150
},

Now we are going get human readable format address for the given latitude and longitude co-ordinates using PHP.

Steps:

1. Getting user entered  latitude and longitude co-ordinates.

2. Sending that url request with co-ordinates we got from user, to that Google Maps Reverse Geocode API.

3. Google Maps Reverse Geocode API provides JSON formatted string output, now converting that JSON formatted string into JSON object using json_decode() method.

4. Finally getting human readable address from the JSON output.

Here is the script to download

download google maps reverse geocode api in php source code free

Download

 

Here is sample script to convert given geo-coordinates into human readable format address using Google Maps Reverse geocode API.

Know more about Google Maps Reverse Geocoding service..

Posted by:

muni

1 Comment

Leave A Comment

Your email address will not be published. Required fields are marked (required):

Related articles

Back to Top