简体   繁体   中英

Python mapbox showing blank map in Jupyter

I have a problem about not showing show Mapbox in Jupyter.

I check if it works via https://api.mapbox.com/?access_token=myaccesstoken it always returns {"api":"mapbox"}

I updated token many times but nothing changed. How can I fix it?

Here is my code snippet.

import plotly.graph_objects as go    
import plotly.io as pio              
import plotly.express as px

access_token = 'my-mapbox-token'
px.set_mapbox_access_token(access_token)

fig = px.density_mapbox(...)
fig.update_layout(margin={"r":0,"t":30,"l":0,"b":0})
fig.show()

Can you try to pass the token with your first update_layout() call, in which you should set your map style:

fig.update_layout(mapbox_style="dark", mapbox_accesstoken=token)

See this example for reference:

https://plotly.com/python/mapbox-layers/

-> Go to example "Dark tiles from Mapbox service.."

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM