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
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.
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");
?>
You may also want a reverse process like Getting latitude and longitude coordinates from given address.
Posting Komentar