Created
October 5, 2018 14:24
-
-
Save enzzc/3fca73d2044ab655418ade5dd1ccaae9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
MAPS_API_KEY = 'secret' | |
def geocode(address): | |
url = 'https://maps.googleapis.com/maps/api/geocode/json' | |
params = { | |
'address': address, | |
'key': MAPS_API_KEY | |
} | |
r = requests.get(url, params=params) | |
data = r.json()['results'] | |
if data: | |
lat = data[0]['geometry']['location']['lat'] | |
lng = data[0]['geometry']['location']['lng'] | |
return lat, lng | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment