dash: Plotly express scatter_mapbox does not show map[BUG]
I am trying to insert a scatter_mapbox
map with openstreetmap layer following this example:
https://plot.ly/python/mapbox-layers/#openstreetmap-tiles-no-token-needed
But I only get a blank figure. scatter_geo
works normally. The above example works in a Jupyter notebook but not in m dash app
Is this a known bug?
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 7
- Comments: 22 (8 by maintainers)
Hi, I could solve the problem adding the mapbox_style param, and the center,
fig = ( px.density_mapbox( data_frame=grouped_data, lat=lat,lon=lon, center=dict( lat=8.584314, lon=-75.95781 ), z=grouped_data.columns[-1], hover_name=municipio, color_continuous_scale=px.colors.sequential.Agsunset, zoom=7, radius=20, mapbox_style="carto-positron", ) )
One thing to look out for is to ensure that lat and lon are correctly scaled: lat should be within [-90,90] and lon should be within [-180,180], which it looks like is not the case in the gist above (sorry @fccoelho for never responding, that was rude of me!) … I don’t believe that Mapbox accepts lat values of
7461860.1500282902270
?Note: Same behavior, but for me it was ublock origin blocking the request.
mapbox_style=“carto-positron” Solved the issue for me. You can do fig.update_layout(mapbox_style=“carto-positron”)
This seems like a mapbox token-related issue… The examples on our site are loading for me e.g. https://plotly.com/python/scattermapbox/ and if they’re loading in your notebook it means you’ve got a token installed. Is that token set up in your Dash app? If you open up the Javascript Developer Tools you might see some error messages that guide you but my guess is that the Mapbox token you’re using somehow doesn’t work with your app, possibly because it’s locked to work only on some domains.