Skip to content

Instantly share code, notes, and snippets.

@code-shoily
Created December 27, 2013 17:11
Show Gist options
  • Save code-shoily/8149745 to your computer and use it in GitHub Desktop.
Save code-shoily/8149745 to your computer and use it in GitHub Desktop.
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