Skip to main content

Easy geocoding, reverse geocoding, driving directions, and local search in Python via Google.

Project description

An easy-to-use Python wrapper for the Google Maps and Local Search APIs.

Geocoding: convert a postal address to latitude and longitude

>>> from googlemaps import GoogleMaps
>>> gmaps = GoogleMaps(api_key)
>>> address = 'Constitution Ave NW & 10th St NW, Washington, DC'
>>> lat, lng = gmaps.address_to_latlng(address)
>>> print lat, lng
38.8921021 -77.0260358

Reverse Geocoding: find the nearest address to (lat, lng)

>>> destination = gmaps.latlng_to_address(38.887563, -77.019929)
>>> print destination
Independence and 6th SW, Washington, DC 20024, USA

Local Search: find places matching a query near a given location

>>> local = gmaps.local_search('cafe near ' + destination)
>>> print local['responseData']['results'][0]['titleNoFormatting']
Vie De France Bakery & Cafe

Directions: turn-by-turn directions, distance, time, etc. from point A to point B

>>> directions = gmaps.directions(address, destination)
>>> print directions['Directions']['Distance']['meters']
>>> print directions['Directions']['Duration']['seconds']
>>> for step in directions['Directions']['Routes'][0]['Steps']:
...     print step['descriptionHtml']
Head <b>east</b> on <b>Constitution Ave NW</b> toward <b>9th St NW</b>
Take the 2nd <b>right</b> onto <b>7th St NW</b>
Turn <b>left</b> at <b>Independence Ave SW</b>

This software is in no way associated with or endorsed by Google Inc. Use of the Google Maps API is governed by its Terms of Service: Note in particular that you will need your own Google Maps API key to use this service, and that there are rate limits to the number of requests you can make.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for googlemaps, version 1.0.2
Filename, size File type Python version Upload date Hashes
Filename, size googlemaps-1.0.2.tar.gz (60.9 kB) File type Source Python version None Upload date Hashes View
Filename, size googlemaps-1.0.2.win32.exe (71.6 kB) File type Windows Installer Python version any Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page