有什么方法(使用rest API 会很棒)获取与地理坐标对应的街道名称?我认为这个名字是地理编码,谷歌有这个API吗?我是 PHP 开发人员。
例。
<?php
cor="38.115583,13.37579";
echo(geoname(cor)); // this prints: Foro Umberto I - 90133 Palermo
?>
所以函数的输出是街道名称、邮政编码和城市。感谢您提供任何帮助和脚本示例!
最佳答案
是的,只需使用 Google Maps API 中的“反向地理编码”功能即可:http://code.google.com/apis/maps/documentation/geocoding/#ReverseGeocoding
下面是一些示例代码:
$lat="38.115583";
$long = "13.37579";
$url = "http://maps.googleapis.com/maps/api/geocode/json?latlng=$lat,$long&sensor=false";
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_HEADER, false);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_ENCODING, "");
$curlData = curl_exec($curl);
curl_close($curl);
$address = json_decode($curlData);
print_r($address);
关于php - 地理坐标到街道名称,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5253160/