<?php
function getGeocodeAddress($lat, $long)
{
$url = "https://maps-api-ssl.google.com/maps/api/geocode/json?latlng=" . $lat . "," . $long . "&sensor=true";
if (is_array($jsondata) && $jsondata['status'] == "OK") { $addressComponents = $jsondata['results'];
for ($i = 0; $i < count($addressComponents); $i++) { for ($j = 0; $j < count($addressComponents[$i]['address_components']); $j++) { $typeName = $addressComponents[$i]['address_components'][$j]['types'][0];
if ('locality' == $typeName) {
return strtolower($addressComponents[$i]['address_components'][$j]['long_name']); }
}
}
}
return null;
}
echo getGeocodeAddress('-23.6453505', '-46.7914009');
PD9waHAKZnVuY3Rpb24gZ2V0R2VvY29kZUFkZHJlc3MoJGxhdCwgJGxvbmcpCiAgICAgICAgewogICAgICAgICAgICAkdXJsID0gImh0dHBzOi8vbWFwcy1hcGktc3NsLmdvb2dsZS5jb20vbWFwcy9hcGkvZ2VvY29kZS9qc29uP2xhdGxuZz0iIC4gJGxhdCAuICIsIiAuICRsb25nIC4gIiZzZW5zb3I9dHJ1ZSI7CgogICAgICAgICAgICAkZGF0YSA9IEBmaWxlX2dldF9jb250ZW50cygkdXJsKTsKICAgICAgICAgICAgJGpzb25kYXRhID0ganNvbl9kZWNvZGUoJGRhdGEsIHRydWUpOwogICAgICAgICAgICBpZiAoaXNfYXJyYXkoJGpzb25kYXRhKSAmJiAkanNvbmRhdGFbJ3N0YXR1cyddID09ICJPSyIpIHsKICAgICAgICAgICAgICAgICRhZGRyZXNzQ29tcG9uZW50cyA9ICRqc29uZGF0YVsncmVzdWx0cyddOwogICAgICAgICAgICAgICAgZm9yICgkaSA9IDA7ICRpIDwgY291bnQoJGFkZHJlc3NDb21wb25lbnRzKTsgJGkrKykgewogICAgICAgICAgICAgICAgICAgIGZvciAoJGogPSAwOyAkaiA8IGNvdW50KCRhZGRyZXNzQ29tcG9uZW50c1skaV1bJ2FkZHJlc3NfY29tcG9uZW50cyddKTsgJGorKykgewogICAgICAgICAgICAgICAgICAgICAgICAkdHlwZU5hbWUgPSAkYWRkcmVzc0NvbXBvbmVudHNbJGldWydhZGRyZXNzX2NvbXBvbmVudHMnXVskal1bJ3R5cGVzJ11bMF07CiAgICAgICAgICAgICAgICAgICAgICAgIGlmICgnbG9jYWxpdHknID09ICR0eXBlTmFtZSkgewogICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHN0cnRvbG93ZXIoJGFkZHJlc3NDb21wb25lbnRzWyRpXVsnYWRkcmVzc19jb21wb25lbnRzJ11bJGpdWydsb25nX25hbWUnXSk7CiAgICAgICAgICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0KICAgICAgICAgICAgcmV0dXJuIG51bGw7CiAgICAgICAgfQplY2hvIGdldEdlb2NvZGVBZGRyZXNzKCctMjMuNjQ1MzUwNScsICctNDYuNzkxNDAwOScpOw==