地理坐标为街道名 [英] Geographical coordinates to street names

查看:115
本文介绍了地理坐标为街道名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何方式(以其他 API将是真棒),以获得对应于地理坐标街叫什么名字?我觉得这个名字是地理编码,就谷歌有这样的API?林PHP开发人员。

is any way (with a rest API will be awesome) to get the Street name corresponding to a Geographical coordinate? I think the name is geocoding, do google have this API? Im PHP developer.

防爆。

<?php 
cor="38.115583,13.37579";
echo(geoname(cor)); // this prints: Foro Umberto I - 90133 Palermo  
?>

所以,函数的输出是街道名称,邮政code和城市。感谢您的帮助和脚本例子!

So the output of the function is the street name, the postal code and the city. Thanks for any help and scripts examples!

推荐答案

是的,只要使用谷歌地图API中的反向地址解析功能:<一href=\"http://$c$c.google.com/apis/maps/documentation/geocoding/#ReverseGeocoding\">http://$c$c.google.com/apis/maps/documentation/geocoding/#ReverseGeocoding

Yes, just use the "Reverse Geocoding" function in the Google Maps API: http://code.google.com/apis/maps/documentation/geocoding/#ReverseGeocoding

下面是一些例子code:

Here's some example code:

$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);

这篇关于地理坐标为街道名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆