-
Notifications
You must be signed in to change notification settings - Fork 141
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
Inconsistent issue when removing a split map control from an ipyleaflet map #850
Comments
Hey @lopezvoliver! I looked into this, and it turned out to be quite complicated. The cause of the issue is two-fold:
There are some workarounds you could try:
|
Thanks @iisakkirotko for the insight It took a while to examine this in detail but I finally managed to make a workaround using your first suggestion which I preferred to avoid having to restore the state of the map. The workaround I ended up doing is what you suggested, but by doing a full round-trip between the map and the solara server by updating a solara reactive variable: So when "removing" the control I set a dummy reactive variable to True: self.remove(self.split_map_control)
map_type_dummy.set(True) which is also a trait of the Map: class Map(ipyleaflet.Map,):
map_type = traitlets.Unicode().tag(sync=True)
map_type_dummy = traitlets.Bool(False).tag(sync=True) # PATCH dummy trait
@observe("map_type_dummy")
def _on_map_dummy(self, change):
if change.new:
map_type_dummy.set(False)
self.set_stack_mode() # HERE I update the layers, after a "round-trip"
.....
Map.element(
zoom=zoom.value,
on_zoom=zoom.set,
map_type=map_type.value,
map_type_dummy = map_type_dummy.value
) Here's the full code Interestingly, here's an attempt at the workaround which relies on a Looking forward to your fix to leaflet-splitmap getting merged too |
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?
The text was updated successfully, but these errors were encountered: