如何将 Latitude/Longitude 转换为地址
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 反向地理编码:
如果您想从地址获取纬度和经度,则该过程称为地理编码,可以使用 Google 地图 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 地图 API,是可行的方法。
我写了一些代码,这些代码有效,但只能获取纬度和经度 但我想从街道地址转换纬度和经度。
<!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 反向地理编码:
如果您想从地址获取纬度和经度,则该过程称为地理编码,可以使用 Google 地图 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 地图 API,是可行的方法。