no relocation after dl.Map center change in callback
dedtadeas opened this issue · comments
dedtadeas commented
Hi,
I have a simple map with a callback and I want to relocate when the button is clicked.
dbc.Button(
"xxx", id="dum", className="mb-2", style={"width": "100%"}
)
html.Div(
children=[
dl.Map(
children=[
tile_layer,
dl.LayerGroup(id='dynamic-layers')
],
zoom=17,
zoomDelta=0.1,
center=[53.839741676507415, 8.76634112590542],
style={
"width": "100%",
"height": "100%",
"display": "block",
"background": "black",
},
id="fps-map",
)
],
className="map-div",
style={"flex": "1"},
)
@app.callback(
Output("fps-map", "center"),
[Input("dum", "n_clicks")],
)
def update_map_center(n_clicks):
ctx = dash.callback_context
no_update = dash.no_update
if not ctx.triggered:
return [], no_update
return [49.080249309032915,16.35538617966371]
Emil Haldrup Eriksen commented
This behavior is by design. Did you try the viewport
property? https://www.dash-leaflet.com/components/map_container#a-manipulating-the-viewport