【发布时间】:2012-04-29 06:14:43
【问题描述】:
我有一个包含确切地址(街道、编号、城市、地区/地区、国家/地区)的数据库。但是,我想知道如果我们在纽约,是否有办法使用 Google API 来获取城市的区域(例如“曼哈顿”)?
我已经在数据库中的所有其他信息,所以如果有的话我只需要地区(当然这只会在大城市中)......
更新:
我在http://www.techques.com/question/1-3151450/Google-geolocation-API---Use-longitude-and-latitude-to-get-address 上找到了这个函数,并尝试将formatted_address 更改为子本地(甚至是其他类似short_name 等),但它没有返回任何内容......任何帮助将不胜感激!谢谢!!
function reverse_geocode($lat, $lon) {
$url = "http://maps.google.com/maps/api/geocode/json?latlng=$lat,$lon&sensor=false";
$data = json_decode(file_get_contents($url));
if (!isset($data->results[0]->formatted_address)){
return "unknown Place";
}
return $data->results[0]->formatted_address;
}
【问题讨论】:
标签: php google-maps-api-3 geolocation geocoding jquery-gmap3