简体   繁体   English

Google map api - 如何从纬度/经度获取地名

[英]Google map api - How to Get the Place's Name from lat/lng

Greetings i was searching for hours and I haven't found anything remotely close to this.问候我搜索了几个小时,但我没有发现任何与此相关的东西。

I am trying to use Distance Matrix API , However as an input the api needs the Origin Address aka Name and Destination as well.我正在尝试使用Distance Matrix API ,但是作为输入,api 还需要 Origin Address aka NameDestination But i can only provide Origin's Lat/Lng and Destination's Lat/Lng from which i get them using my own markers .但我只能提供 Origin 的 Lat/Lng 和 Destination 的 Lat/Lng,我可以使用我自己的markers从中获取它们。

Is it possible to get the place's Name and Address from Lat/Lng of the given origin?是否可以从给定来源的 Lat/Lng 获取该地点的名称和地址? Or Am i in whole wrong path to achieve this?或者我是在完全错误的道路上实现这一目标吗? any suggestion would be appreciated.任何建议将不胜感激。 thank you.谢谢你。

For your information.供您参考。 DistanceMatric Api works not only with string addresses it also works with lat/lng, place_id as well. DistanceMatric Api 不仅适用于字符串地址,还适用于 lat/lng、place_id。 Go through below doc https://developers.google.com/maps/documentation/distance-matrix/intro通过以下文档https://developers.google.com/maps/documentation/distance-matrix/intro

So, no need to convert your lat,lng to string addresses.(otherwise simply api hits will increase)因此,无需将您的 lat,lng 转换为字符串地址。(否则简单的 api 点击量会增加)

If you want to see result.如果你想看到结果。 Check below api.检查下面的api。 https://maps.googleapis.com/maps/api/distancematrix/json?units=imperial&origins=40.6655101,-73.89188969999998&destinations=40.6905615%2C-73.9976592&key=[API_KEY] https://maps.googleapis.com/maps/api/distancematrix/json?units=imperial&origins=40.6655101,-73.89188969999998&destinations=40.6905615%2C-73.9976592&key=[

Note: Replace API_KEY with your api key注意:将 API_KEY 替换为您的 api 密钥

You can use the latitude/longitude coordinates for origin and destination parameters.您可以使用纬度/经度坐标作为起点和目的地参数。 Its in the documentation https://developers.google.com/maps/documentation/distance-matrix/intro它在文档中https://developers.google.com/maps/documentation/distance-matrix/intro

But if you really want to get the address from latlng you can reverse geocode it like this:但是如果你真的想从 latlng 获取地址,你可以像这样反向地理编码:

https://maps.googleapis.com/maps/api/geocode/json?latlng=40.714224,-73.961452&key=YOUR_API_KEY

here is the link to the documentation for your reference https://developers.google.com/maps/documentation/geocoding/start这是文档的链接,供您参考https://developers.google.com/maps/documentation/geocoding/start

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM