使用 Google 地图 API 进行反向地理编码
我正在研究 JavaScript Google Map API(版本 3),更准确地说,正在研究反向地理定位。在官方文档的帮助下,我成功了为了执行反向地理编码,我找到了与纬度和经度坐标对应的地址。
但我找不到如何到达与地址绑定的名称。是否可以?怎样才能执行呢?
谢谢你。
卡米尔。
I'm working on the JavaScript Google Map API (Version3) and more precisely on the reverse geolocation. With the help of the official documentation, I successed to perform the reverse geocoding, I found the address corresponding to the latitude and longitude coordonates.
But I can't find how to reach the name bound to the address. Is it possible? How can it be performed?
Thanks you.
Camille.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您确实需要循环并对谷歌在这些点发现的内容进行多次检查,一个小脚本来实际读取/循环返回的数据将是(在 PHP 中):
现在基于文档:
并且:
您只需要第一个结果即可获得您想要的结果(或者至少在那里搜索它
$data->results[0]->
。因此,请阅读类型并基于您可以检查是否出现您想要的结果:
You really need to loop and do multiple checks of what google found at these points a small script to actually reads/loop the returned data would be (in PHP):
Now based on the documentation:
And:
You only need the first result to get what you want (or at least to search for it there
$data->results[0]->
.So have a read of the types and based on that you can check if the result you want present or not:
Google Map API 有一个地点查找 API 的测试版。我想这就是你所寻找的。基本上,您传递一个纬度/经度或地址,谷歌会对该地址进行反向查找到一个地名(如果它在其数据库中)。
请参阅他们的文档:
http://code.google.com/apis/maps/documentation/places/
摘自他们对 Places API 的介绍:
Places API 有两种相关的基本请求类型:地点搜索请求和地点详细信息请求。地点搜索请求发起对所提供位置周围“地点”的请求,通常通过地理位置提供(以便用户可以搜索他们当前所在的地点或附近的地点)。 Places API 返回靠近所提供位置的候选地点列表,然后用户可以对原始搜索中返回的特定实体发起地点详细信息请求。
Google Map API has a Beta release version of a place lookup API. I think this is what your looking for. Basically, you pass a lat/lng or address and google does a reverse lookup of the address to a place name (if its in its database).
See their documentation at:
http://code.google.com/apis/maps/documentation/places/
Excerpt from their intro on Places API:
The Places API has two basic types of requests, which are related: Place Search requests and Place Details requests. A Place Search request initiates a request for "places" around a provided location, often provided via geolocation (so that a user can search for the Place they are currently located or Places nearby). The Places API returns a list of candidate places that are near the provided location and the user can then initiate a Place Details request on a specific entity returned in the original search.