3
    import gmaps
    import gmaps.datasets
    gmaps.configure(api_key="AI...") # Your Google API key

    locations = gmaps.datasets.load_dataset("starbucks_uk")

   fig = gmaps.Map()
    starbucks_layer = gmaps.symbol_layer(
        locations, fill_color="green", stroke_color="green", scale=2)
    fig.add_layer(starbucks_layer)
    fig

I am currently trying to load this in my jupyter notebook, however the map will not display

Any help on this would be appreciated!

7
  • Do you have the gmaps Juypter extension installed and activated? jupyter nbextension enable --py --sys-prefix gmaps. More info. Commented Nov 15, 2017 at 17:20
  • @JanTrienes How do I do that. Do i put $ pip install gmaps in a command line or do I put that in the jupyter terminal?
    – Harry
    Commented Nov 15, 2017 at 17:32
  • Try executing the command on your command line, restart your notebook and try again. You need to have gmaps installed for this to work. One way is pip install gmaps on your shell. Commented Nov 15, 2017 at 17:33
  • @JanTrienes to install gmaps would I put that code in the jupyter terminal?
    – Harry
    Commented Nov 15, 2017 at 17:37
  • You would execute that command on the command line of your machine. Commented Nov 15, 2017 at 17:38

1 Answer 1

3

first, You need to write this code in your terminal:

jupyter nbextension enable --py gmaps

and then make sure in your terminal you get "validating ok" in your terminal.

for the datasets itself, you need to write 'starbucks_kfc_uk' not "starbucks_uk"

next code should be like this:

starbucks_df = df[df['chain_name'] == 'starbucks']
starbucks_df = starbucks_df[['latitude', 'longitude']]

starbucks_layer = gmaps.symbol_layer(
    starbucks_df, fill_color="green", stroke_color="green", scale=2
)
fig = gmaps.figure()
fig.add_layer(starbucks_layer)
fig

And this is my result:

enter image description here

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.