Closed Martenz closed 1 week ago
Yep, this is really useful. For some reason MapLibre does not ship with such a control by default but I will add a custom one.
Nice! If I can contribute in some way I'll keep an eye on the repo. Meanwhile thanks for the support. I did something but only in JS with custom controls https://maplibre.org/maplibre-gl-js/docs/API/interfaces/IControl/ It would be nice to have it in python and maybe extend it in future for also other custom controls like style dynamic changes (opacity, colors etc..)
Yep, that's how it works. If you want pure Python you need to use Map.set_layout_property
in combination with a Shiny ui element or a Jupyter interaction element.
In general you do dynamic changes with Map.set_layout_property
and Map.set_paint_property
. Take a look at this example using Shiny. You need to run the example in order to get the select boxes.
Leafmap has a widget for changing MapLibre layer opacity and color interactively. It is not as nice as the leaflet built-in LayerControl, but it does work. https://leafmap.org/maplibre/color_switcher/
https://github.com/eodaGmbH/py-maplibregl/assets/5016453/ec9898ea-cb03-4e20-bb2f-c82ea1e77067
The PMTiles Viewer has a layer control for changing layer visibility. It is a good example.
It would be nice to have also a layer list control that can be added. Like leaflet Layer Groups / Layer Controls in order to control layer visibility in case of multiple layer added to the map.