php 如何从谷歌地图中的经纬度获取地址位置。?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19511597/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to get address location from latitude and longitude in Google Map.?
提问by Boris Kuzevanov
So I have latitude and longitude Like 44.4647452
and 7.3553838
. I need to get address like: Milan, Italy, str. Kennedy 89.
所以我有纬度和经度 Like44.4647452
和7.3553838
。我需要得到这样的地址:米兰,意大利,海峡。肯尼迪 89.
How I can do it?
我该怎么做?
回答by user2092317
Simply pass latitude, longitude and your Google API Key to the following query string, you will get a json array, fetch your city from there.
只需将纬度、经度和您的 Google API 密钥传递给以下查询字符串,您将获得一个 json 数组,从那里获取您的城市。
https://maps.googleapis.com/maps/api/geocode/json?latlng=44.4647452,7.3553838&key=YOUR_API_KEY
https://maps.googleapis.com/maps/api/geocode/json?latlng=44.4647452,7.3553838&key=YOUR_API_KEY
Note: Ensure that no space exists between the latitude and longitude values when passed in the latlng parameter.
注意:在传递 latlng 参数时,确保纬度和经度值之间不存在空格。
回答by Sajuna Fernando
What your looking for is Reverse Geo Coding. Have a look at this example here. https://developers.google.com/maps/documentation/javascript/examples/geocoding-reverse
您正在寻找的是反向地理编码。在这里看看这个例子。https://developers.google.com/maps/documentation/javascript/examples/geocoding-reverse
回答by Dinesh Prajapati
You have to make one ajax call to get the required result, in this case you can use Google API to get the same
您必须进行一次 ajax 调用才能获得所需的结果,在这种情况下,您可以使用 Google API 来获得相同的结果
http://maps.googleapis.com/maps/api/geocode/json?latlng=40.714224,-73.961452&sensor=true/false
Build this kind of url and replace the lat long with the one you want to. do the call and response will be in JSON, parse the JSON and you will get the complete address up to street level
构建这种 url 并将 lat long 替换为您想要的。调用和响应将在 JSON 中,解析 JSON,您将获得街道级别的完整地址