简体   繁体   中英

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:

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. Here is sample python code to run this conversion:

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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