Last active
January 3, 2016 06:39
-
-
Save cclauss/8424161 to your computer and use it in GitHub Desktop.
Use Pythonista's Location module to print the current street address
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 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