Hi guys, I will try to give an example as clear as possible, my code is on another network so I can’t copy paste it.
So I have a function that creates a scattermap figure
I pass a list of longitude points and langitudes for my map.
I have 2 layers to the map.
now I have a really simple callback:
def temp(n_clicks, map_fig):
return go.Figure() # Returns an empty figure
I click on the buttons 2 times.
The first time I see in the console the figure data as I expect,
now after I click I expect to see the map as an empty figure, but no it doesn’t update the map.
and the second time I click, it prints the exact same data it printed before meaning the figure really didn’t change.
Now for clarifications:
- I checked the id names they’re right (the callback runs after all)
- My real goal is to return a new scattermapbox with a different set of points, I am using an empty figure for simplification of the question, when using the scattermapbox with new points I have the exact same problem.
- I tried looking at the map element in the inspect while clicking the button it shows on the div created by the graph figure with the id data -dash-is-loading for a second and then it disappears, and nothing changes below the div with the id.
any idea why this happens?
I get an error Uncaught (in promise) Error: Mapbox error.
Any idea what it means and if its the cause of the problem?
Hi! It’s hard to tell, because I can’t see your code, but I guess I had a very similar problem today. My code (simplified) looked like this:
stations_map_data = go.Scattermapbox(lon = active_stations.lon,lat = active_stations.lat)
stations_map = go.Figure(data=stations_map_data)
When I wanted to change the points ploted on the map, I called this function again and passed the result to Dash. When I printed
stations_map, it was changed, but the old version was still displayed.
I have no idea why, but changing to this version helped:
stations_map = px.scatter_mapbox(active_stations,lat=active_stations.lat, lon=active_stations.lon)
It is basically replacing
Hi! thanks for the answer, I will definitely check this out Saturday when I go back to work and update you if it worked!
@Matan Did the solution suggested by @katterrina work?
Welcome to the community!
There was an issue with dash 2.7.0, please make sure you are running a newer version than that.
I’m still having the issue even while using the latest version of dash.
I’ve posted a minimal example here: Go Scattermapbox Does Not Update
Could you check it out?
no it didn’t work.
my bad i didn’t update the post.
I wasn’t able to solve this issue either so I opened a github issue about this.
So, I believe that this has to do with the very first render of the map. If there is no data, the map doesnt render changes to the data properly.
If the map has some placeholder info, and then you update, it works properly.
This very well could be an issue with mapbox itself, as this is a library outside of plotly.