Created
December 27, 2013 17:11
-
-
Save code-shoily/8149745 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
from simplejson import loads | |
from urllib2 import urlopen | |
def get_nearest_locations(lat, lng): | |
url = 'http://maps.google.com/maps/api/geocode/json?latlng={},{}&sensor=true' | |
output = loads("".join(map(lambda i: i.replace(r"\n\t ", "").strip(), | |
urlopen(url.format(lat, lng)).readlines()))) | |
return { | |
"original_output": output, | |
"extracted_info": map(lambda i: (i["formatted_address"], i["types"]), output["results"]), | |
} | |
# For Example: | |
nlm = get_nearest_locations(23.750123, 90.368802) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment