previously explain about getting latitude and longitude values from Google Maps API, based on the town, city or country location.
PHP function for Reveres Geocoding
<?php function getaddress($lat,$lng) { $url = 'http://maps.googleapis.com/maps/api/geocode/json?latlng='.trim($lat).','.trim($lng).'&sensor=false'; $json = @file_get_contents($url); $data=json_decode($json); $status = $data->status; if($status=="OK"){ return $data->results[0]->formatted_address; } else{ return false; } } ?>
<?php $lat= 26.754347; //latitude $lng= 81.001640; //longitude $address= getaddress($lat,$lng); if($address){ echo $address; }else{ echo "Not found"; } ?>
No comments:
Post a Comment