-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG] Dynamic update of Mapbox style not working #1152
Comments
Thanks @bluenote10 |
Plotly.react appears to be working fine in this demo. |
Also using dash the example below works. import dash
import dash_core_components as dcc
import dash_html_components as html
from dash.dependencies import Input, Output
import plotly.graph_objects as go
def init_app():
app = dash.Dash(__name__)
graph = dcc.Graph(
id='graph',
style={
'width': '100%',
'height': '1000px',
}
)
switch = dcc.RadioItems(
id='switch',
options=[
{'label': 'Map A', 'value': 'A'},
{'label': 'Map B', 'value': 'B'},
],
value='A',
)
app.layout = html.Div(children=[
html.Div(children=[switch]),
html.Div(children=[graph]),
])
@app.callback(
Output('graph', 'figure'),
[Input('switch', 'value')],
)
def update_figure(value):
if value == "A":
mapbox_style = "stamen-terrain"
else:
mapbox_style = "stamen-watercolor"
return dict(
data=[
go.Scattermapbox()
],
layout=dict(
mapbox=dict(style=mapbox_style)
),
)
return app
if __name__ == '__main__':
app = init_app()
app.run_server(debug=True) |
But it seems to be a problem when the style type is an object. |
Tracked in plotly/plotly.js#4719. |
Is there any update on this? I'm having the same issue. |
Which version are you using? |
Yes, thank you. I figured out the problem. Animate=True was preventing the update for some reason. |
I'm having a similar problem today with
I have an app that, among other things, displays a trace on a map. The trace shall be updated based on a selection or when a different trace is loaded. When the callback is called, everything but the trace on the map is updated as expected: the centre (the map re-centres based on the new coordinates) and the datapoints (see image below). In other words, the old "painted trace" remains and the new one is not painted while all the "data" (map centre, datapoints) are updated. If I replace The layout:
The callback and an external function that generates the fig. I believe that generating the figure in an external function is not the issue because I do that for another map in the app and that works just fine.
|
Hi @gaumarjos , it's an open issue with plotly.js, you have a workaround in its thread: plotly/plotly.js#6363 |
Hi I have a similar problem where my tiles do not update after a callback unless I refresh the page. See here . Can someone guide me towards a solution /workaround in python? |
Let's continue this discussion in plotly/plotly.js#6444 - the original issue here was fixed a long time ago, then some related issues popped up again, so this issue is not helpful anymore. |
Context
Please provide us your environment so we can easily reproduce the issue.
pip list | grep dash
Browser versions (but most likely not a frontend issue):
Describe the bug
I have a use case which requires to dynamically set the style of a Mapbox map, for instance to modify the underlying tile server. It looks like dynamic updates of mapbox styles do not lead to an update of the map. Minimal reproducing example:
According to the logging output (and the title change) it is clear that the update from the radio button is working properly. However the map does not change accordingly. Only the initial setting is relevant (swapping the if condition simply shows the other tile server unconditionally).
It looks like the behavior is not specific to just the tile server settings -- other modifications also do not seem to update.
Expected behavior
I would have expected the map to change according to the changes.
The text was updated successfully, but these errors were encountered: