[BUG] H3 layers are not fully rendered in Map when layer is swapped
Context
When i use ScatterPlotLayers in my Map, i can dynamically replace the layers and the map redraws as expected.
https://github.com/user-attachments/assets/70122b1a-41e9-483c-970c-43d691c80440
However, when I use H3HexagonLayer and try to do the same thing, the map never fully redraws until i pan or zoom the map. The outlines of the hexagons are being drawn.
https://github.com/user-attachments/assets/51e6c247-2983-43f7-9aa9-1ccb9baefb2d
Resulting behaviour, error message or logs
No logs/warnings/errors.
Environment
- OS: Mac Sequoia 15.6.1
- Browser: VSCode/Cursor using
IPython.display - Python 3.13.5
- Lonboard Version: [e.g. 0.13.0]
Steps to reproduce the bug
- build h3 hexagon layers that i can dynamically switch between with a slider widget
- create map and set first h3 layer (doesn't render fully until panning/zooming)
- on slider change, dynamically replace the map's layer with pre-computed layer
For clarity, when I say "replace the map's layer" I mean:
map_widget = Map(...)
slider = widgets.IntSlider(...)
def on_slider_change(change):
current_minute_idx = change["new"]
new_layer = bin_layers[current_minute_idx]
map_widget.layers = [new_layer]
slider.observe(on_slider_change, names="value")
I'm creating the layers as follows
bin_layers = {}
for ... in range(...):
colors = ...
# Create H3 layer
layer = H3HexagonLayer(layer_table, get_hexagon=layer_table.column("h3_index"))
layer.get_fill_color = colors
Actually, if I enable high_precision (docs) then the rendering works as expected on change, but it is much less performant.
I think this is likely related to https://github.com/developmentseed/lonboard/issues/994.
I think the core is a mismatch between the Jupyter/widget state and the deck.gl state. Because as you see in the map, it renders correctly once you pan the map a little.
I agree this is a bug but not 100% sure yet how to solve it.
Perhaps I need to experiment with updateTriggers here.
Do you happen to have a fully reproducible example?
Interestingly, if I use a coarser resolution for my h3 cells, then it works as expected. Seems like the issue appears with h3 resolution >=6.
Anyways, try out the dataset and notebook below