Black Lives Matter. Please consider donating to Black Girls Code today.

Mapbox default center, zoom behavior

Hello! I use the solution to this topic here to determine a zoom and center for my mapbox just before I create it, however I’ve noticed that upon loading up my dash page and creating the map for the first time, that first time creates like a default center and zoom level.

Let me explain with an example, I open my page, select some stuff and then dash creates a map for me with a center of (20, 30) and zoom of 15. Then with the page still open I select other options and then dash remakes the map with the center at (40, 45) with zoom of 10. If I then zoom in/out or pan or both, then double click the map or hit “the reset” view modebar button, it will set the center to (20, 30) and the zoom level to 15.

This will happen until I exit the page and then come back, where then the first determined zoom and center act as the default.

Does anyone know what this behavior is?

Update: I’ve tried changing the layout so that I pass a whole new dcc.Graph object into the children of a div, thinking a new graph will not retain this behavior. That is not the case, as this behavior remains.

Update2: So I’ve tried to disable the whole view reset just to try it, and so I added this argument when make the dcc.Graph object. config={'doubleClick: False, 'modeBarButtonsToRemove:['resetViewMapbox']} However when I double click the map still resets to the first zoom and center created, and the old behavior still persists. Why can’t I disable the double click event?

Update3: I’ve uploaded a GIF what’s happening. As you can see I load a large data set of gps point, and the map sets a zoom level and center for it. Then when I double click it goes back to that set center and zoom. Then I load a dataset with a smaller area. At first it creates a zoom and center appropriate for the new data. But if I double click it goes back to the original center and zoom for the first and larger set.
Zoom
Hopefully this makes what I’m talking about clearer!

@chriddyp Maybe you know what this behavior is and how to stop it?

I still have no clue why this happening. Can anyone shed any light on this?