1 2 3 4 5 6 7 8 9 10 11 12
| $api_key = "";
// format this string with the appropriate latitude longitude
$url = "http://maps.google.com/maps/geo?q=$lat,$lng&output=json&sensor=false&key=$api_key";
// make the HTTP request
$data = @file_get_contents($url);
// parse the json response
$jsondata = json_decode($data,true);
// if we get a placemark array and the status was good, get the addres
if(is_array($jsondata )&& $jsondata ['Status']['code']==200)
{
$addr = $jsondata ['Placemark'][0]['AddressDetails']['Country']['CountryName'];
} |
Partager