Getting started with Google Maps in Python

Elliott Saslow
Future Vision
Published in
3 min readAug 2, 2018

--

Lets get started with google maps in python! We are going to cover making a basic map, adding different layers to the maps, and then creating driving directions!

Before this article, I did a quick tutorial with basemap in python. In this tutorial, I will cover using the google maps api in jupyter notebook. The first step here is to get an api key from google at this link. Once this is done, you may need to run the following command in terminal and restart jupyter:

jupyter nbextension enable --py gmaps

Once this is complete, you are ready to jump right into making beautiful maps!

Initially, we are going to want to read in our api key. To do this I completed the following steps:

  1. Save the API key in a text file
  2. Write code to read in the key and save it as a variable
with open('apikey.txt') as f:
api_key = f.readline()
f.close

Once this is complete you are ready to use the google maps api. For reference, all the material in this tutorial comes from the documentation which can be found here.

You may also need to do a pip install gmaps prior to working in jupyter.

Once this is done, you can initialize the session with the command:

--

--