Skip to content

Google Maps API wrapper for Python enables convenient caching of Maps API results.

License

Notifications You must be signed in to change notification settings

WZBSocialScienceCenter/gmapswrapper

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Google Maps API wrapper for Python

January 2019, Markus Konrad [email protected] / Berlin Social Science Center

Enables convenient caching of Google Maps API results. So far only the Geocoding API is supported.

Requirements

  • Python 3.4+
  • googlemaps package

Usage

from gmapswrapper import GMapsWrapper

# to enable logging output to console:
import logging 
logging.basicConfig(level=logging.INFO)
logging.getLogger('gmapswrapper').setLevel(logging.INFO)

# "cachedir" must be a writable directory to save the cache file
gmaps = GMapsWrapper('cachedir', api_key='...')

queries = [
    'Reichpietschufer 50, Berlin',
    # ...
]

# Returns dict with address -> result mapping
geocoding_res = gmaps.geocode(queries)
geocoding_res
## {'Reichpietschufer 50, Berlin': [{'address_components': [{'long_name': '50',
##                                                           'short_name': '50',
##                                                           'types': ['street_number']},
##                                                          {'long_name': 'Reichpietschufer',
##  ...

Running this a second time will not query the Google API but take the result from the cache file.

License

Apache License 2.0. See LICENSE file.

About

Google Maps API wrapper for Python enables convenient caching of Maps API results.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages