Skip to content

Instantly share code, notes, and snippets.

@cclauss
Last active January 3, 2016 06:39
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cclauss/8424161 to your computer and use it in GitHub Desktop.
Save cclauss/8424161 to your computer and use it in GitHub Desktop.
Use Pythonista's Location module to print the current street address
import location, webbrowser #, time
def getLocation():
location.start_updates()
# time.sleep(1)
currLoc = location.get_location()
location.stop_updates() # stop GPS hardware ASAP to save battery
return currLoc
def getStreetAddress(loc = getLocation()):
return location.reverse_geocode(loc)[0]
street_address = '{Street}, {City}, {Country}'.format(**getStreetAddress())
print(street_address)
map_URL = 'http://maps.google.com?q=' + street_address.replace(' ', '+')
print(map_URL) # also try safari-http://
webbrowser.open(map_URL)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment