Reputation: 51
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!
Upvotes: 3
Views: 6650
Reputation: 431
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:
Upvotes: 3