0

I'm following this guide in starting with gmaps api and python;

import gmaps
import gmaps.datasets
import pandas as pd


def func():
    # Use google maps api
    gmaps.configure(api_key='MY_API_KEY')  # Fill in with your API key
    # Get the dataset
    earthquake_df = gmaps.datasets.load_dataset_as_df('earthquakes')
    # Get the locations from the data set
    locations = earthquake_df[['latitude', 'longitude']]
    # Get the magnitude from the data
    weights = earthquake_df['magnitude']
    # Set up your map
    fig = gmaps.figure()
    fig.add_layer(gmaps.heatmap_layer(locations, weights=weights))
    return fig

func()

been using this code from the guide (both on pychram and jupyter notebooks) but when i run the code (pychram/jupyter/terminal) I don't get the output map like in the guide. just a nice old-fashion

Process finished with exit code 0
2
  • I think you are missing the last line, which is to call fig Commented Nov 28, 2019 at 14:42
  • sorry, you're right, edited Commented Nov 28, 2019 at 14:49

1 Answer 1

1

Check if it is enabled for jupyter first by running jupyter nbextension list. If you do not see jupyter-gmaps/extension enabled then you need to run this line in terminal jupyter nbextension enable --py gmaps and then run a new jupyter notebook.

Sign up to request clarification or add additional context in comments.

1 Comment

It worked! so thanks, but actually ran into the same problem with gmplot.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.