繁体   English   中英

如何将纬度/经度转换为地址

[英]How to do Convert Latitude/Longitude To Address

我写了一些代码,这些代码工作但只获得纬度和经度,但我想从街道地址转换纬度和经度。

 <!DOCTYPE html> <html> <head> <title>location</title> </head> <body> <script type="text/javascript"> navigator.geolocation.getCurrentPosition(function(position) { document.write("latitude= " + position.coords.latitude); document.write("longitude= " + position.coords.longitude); }); </script> </body> </html> 

尝试使用Google Reverse Geocoding:

反向地理编码示例

如果您想从地址获取纬度和经度,则该过程称为地理编码,可以使用Google Maps API完成。 以下是运行此转换的示例python代码:

import requests
import json

def convert(address):
    URL = 'https://maps.googleapis.com/maps/api/geocode/json?address=' + address + '&key=[INSERT API KEY]&callback=initMap'
    r = requests.get(URL).json()
    return r['results'][0]['geometry']['location']

如果您希望获得基于纬度和经度的地址,那么也可以从Google Maps API获取反向地理编码。

暂无
暂无

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

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