简体   繁体   English

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

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

I wrote some code this codes worked but only get latitude and longitude but ı want convert latitude and longitude from Street adress. 我写了一些代码,这些代码工作但只获得纬度和经度,但我想从街道地址转换纬度和经度。

 <!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> 

Try this for Google Reverse Geocoding: 尝试使用Google Reverse Geocoding:

Reverse geocoding Example 反向地理编码示例

If you want to get latitude and longitude from an address, then the process is called geocoding and can be completed using the Google Maps API. 如果您想从地址获取纬度和经度,则该过程称为地理编码,可以使用Google Maps API完成。 Here is sample python code to run this conversion: 以下是运行此转换的示例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']

If instead you would like to get the address based on the latitude and longitude, reverse geocoding, also from the Google Maps API, is the way to go. 如果您希望获得基于纬度和经度的地址,那么也可以从Google Maps API获取反向地理编码。

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

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