Looking to Build/Redesign a Website or Blog ?

To speak to Rakshit, call +91 968 704 2303

Reverse GeoCoding-Getting Address from Latitude/Longitude

Hello Friends,

Google MAP API provides you the way to get Latitude, Longitude, IP Address if you provide the Address. This is called GeoCoding. Are you stuck where you want Address or Region code from Latitude and Longitude? Now, Google MAP API provides reverse way where you have to pass latitude/longitude and Google will give Address containing City, State, Region Code, Country in response. This is called Reverse GeoCoding.

Below is the PHP code for getting Region Code from latitude and longitude.

$url = “http://maps.google.com/maps/geo?q=30.28,-97.73&output=json&key=ABQIAAAAhdDokCu8GspRD8rZaYYaoRR5dndtY5oS-GFuRoRAautbbsCzexTbXFh0ItLJ_JAtzGaD1Nh8I-kRzQ”;
$json_content = file_get_contents($url);
$data = json_decode($json_content);
echo $data->Placemark[0]->AddressDetails->Country->AdministrativeArea->AdministrativeAreaName;

Thank You!



Leave a Reply

Your email address will not be published.