Open lopezvoliver opened 1 week ago
Hey @lopezvoliver! I looked into this, and it turned out to be quite complicated. The cause of the issue is two-fold:
SplitMapControl
after we remove one of the left/right layers of the control, the removal function throws an error and doesn't finish executing. This is what causes the control to remain after having been removed. I look to fix this in https://github.com/QuantStack/leaflet-splitmap/pull/15.map.layers
is executed before that to map.controls
, resulting in the above behaviour. However, this can't be fixed without introducing performance overhead into Solara, which we'd like to avoid.There are some workarounds you could try:
map_type
changes, and use an effect to then remove the layers.map_type
is changed, like in this snippet. However, this will result in more rerenders of the map, and means that the __init__
function of the map has to restore all state to the map, instead of any of it being stored in the widget state.
I am facing a very difficult issue to trace, so I came up with this almost reproducible example.
This animation shows the demo initially working as expected. Then, I refresh the app and there is an issue with the demo: the split-map control does not get removed correctly.
Setup
Let's start with defining a custom class inheriting from ipyleaflet.Map that can dynamically change between a split map and a "stack" map (layers stacked on top of each other).
I haven't encountered the issue when testing the ipyleaflet code without solara.
Now let's add solara to the equation:
Could you please help diagnose this problem?