I am building a Dash App that uses plotly scattermapbox
graph object. Is there a way to natively (without a callback) let users select a map layout in plotly mapbox? Iโd like users to switch between different styles.
import dash
from dash import dcc
import pandas as pd
df = pd.DataFrame({'x': [1, 2, 3]})
layout = html.Div(
dcc.Graph(id="map"),
dcc.Input(id="inp")
)
@app.callback(
Output('map','figure'),
Input('inpt','value')
)
def fin(val):
# do something
data = []
data.append({
"type": "scattermapbox",
"lat": df["Lat"],
"lon": df["Long"],
"name": "Location",
"showlegend": False,
"hoverinfo": "text",
"mode": "markers",
"clickmode": "event+select",
"customdata": df.loc[:,cd_cols].values,
"marker": {
"symbol": "circle",
"size": 8,
"opacity": 0.7,
"color": "black"
}
}
)
layout = {
"autosize": True,
"hovermode": "closest",
"mapbox": {
"accesstoken": MAPBOX_KEY,
"bearing": 0,
"center": {
"lat": xxx,
"lon": xxx
},
"pitch": 0,
"zoom": zoom,
"style": "satellite-streets",
},
}
return ({'data': data, 'layout': layout})