Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Get latitude, longitude and other data from Google Maps geolocation API
import requests
import json
urlbase = ''
urlend = 'Zurich,Switzerland'
r = requests.get(urlbase+urlend) # request to google maps api
if r.get('results'):
for results in r.get('results'):
latlong = results.get('geometry','').get('location','')
latitude = latlong.get('lat','')
longitude = latlong.get('lng','')
print latitude, longitude
print 'No results'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.