GideonShalev
GideonShalev

Reputation: 95

Mapbox map with plotly in jupyter not showing up

I am using plotly in a Jupyter notebook (python v3.6) and trying to get the example code for mapbox to work (see: https://plot.ly/python/scattermapbox/).

When I execute the cell, I don't get any error, but I see no output either, just a blank output cell. When I mouse over the output cell area, I can see there's a frame there, and I even see the plotly icon tray at the top right, but there doesn't seem to be anything else. When I hit the 'edit chart' button at the bottom right, I get taken to the plotly page with a blank canvas. As far as I can tell, my mapbox api token is valid.

My code looks identical to the example linked above:

data = Data([
    Scattermapbox(
        lat=['45.5017'],
        lon=['-73.5673'],
        mode='markers',
        marker=Marker(
            size=14
        ),
        text=['Montreal'],
    )
])

layout = Layout(
    autosize=True,
    hovermode='closest',
    mapbox=dict(
        accesstoken=mapbox_token,
        bearing=0,
        center=dict(
            lat=45,
            lon=-73
        ),
        pitch=0,
        zoom=1,
        style='light'
    ),
)

fig = dict(data=data, layout=layout)
py.iplot(fig)

What am I doing wrong?

Thx!

Upvotes: 2

Views: 4018

Answers (2)

GideonShalev
GideonShalev

Reputation: 95

D'oh! Was using the wrong mapbox token. I should have used the public token, but instead used a private one. The only error was a js one in the console. Thanks user1561393!

jupyter labextension install plotlywidget

Upvotes: 3

user1561393
user1561393

Reputation: 1005

What is your mapbox_token? My guess is you haven't signed up for Mapbox to get an API token (which allows you to download their excellent tile maps for mapbox-gl). The map's not going to show without this token.

Upvotes: 0

Related Questions