Home » » Get address from Latitude and Longitude Coordinates in php

Get address from Latitude and Longitude Coordinates in php

Written By Unknown on Rabu, 26 September 2012 | 11.10

Get Address from given Latitude and Longitude Coordinates using google map api called Reverse Geocoding. It is the process of converting geographic coordinates (Latitude and Longitude) into addresses. Here is a little php function to get address from latitude and longitude.

The Php Script


<?php
function getAddress($lat, $lon){
$url = "http://maps.googleapis.com/maps/api/geocode/json?latlng=".
$lat.",".$lon."&sensor=false";
$json = @file_get_contents($url);
$data = json_decode($json);
$status = $data->status;
$address = '';
if($status == "OK"){
$address = $data->results[0]->formatted_address;
}
return $address;
}

# Call function
echo getAddress("28.6100", "77.2300");
?>

This will output 46, Hauz Qazi, Chandni Chowk, New Delhi, Delhi 110006, India
You may also want a reverse process like Getting latitude and longitude coordinates from given address.
Share this article :

Posting Komentar

 
Support : Creating Website | Johny Template | Mas Template
Copyright © 2011. Kumpulan Kata Broadcast Blackberry - All Rights Reserved
Template Created by Creating Website Published by Mas Template
Proudly powered by Blogger