go.Scattermapbox doesnot work in Dash

I have the below code to plot my Ebike ride as a plot on map. It works with normal plotly, but not with dash. It doesnot give any error. But Html page returns ‘error loading layout’

import dash
import dash_core_components as dcc
import dash_html_components as html
import pandas as pd
import plotly.graph_objs as go

df = pd.read_csv(‘csv_test\combine.csv’)
df.head()
app = dash.Dash()

data = [go.Scattermapbox(lat=df[‘latitude’], lon=df[‘longitude’], mode=‘markers’, marker=dict(size=8),
text=df[‘rasp_time’])]

layout = go.Layout(autosize=True, hovermode=‘closest’, mapbox=dict(bearing=0,
center=dict(lat=48.5069, lon=9.2038),
pitch=0, zoom=30))
fig = dict(data=data, layout=layout)

app.layout = html.Div([
dcc.Graph(id=‘graph’, figure=fig)
])

if name == ‘main’:
app.run_server(debug=True)

Hello,

do you have a Mapbox account and a public Mapbox Access Token ? You need them to plot on Mapbox maps : https://plot.ly/python/scattermapbox/#mapbox-access-token.

Hope it helps!

1 Like

This resolved my issue :slight_smile: thanks

Hi,

I have a mapbox access key. I have a map style and tried displaying it in Dash and it worked.
Now I created new map style and when I try displaying this in dash, the map is getting loaded but displays empty tiles on screen.

When I tried thsi new style using jupyter notebook it worked. only on Dash its not working

Any idea what is wrong?

Regards,
Sharada

Hi,
I am unfortunately not deeply versed in Mapbox. I don’t know how to help you on this one, sorry :frowning:

Hey @sharadas,

I got the same problem and I solved by creating a new map box access token.

It was showing everything correctly on jupyter notebook using the default access token, but when I changed to Dash it was not displaying anything except the legends.

So, I created a new map box access token ( different than the default ), updated the code in my Dash app and it worked