eodaGmbH / py-maplibregl

Python bindings for MapLibre GL JS
https://eodagmbh.github.io/py-maplibregl/
MIT License
31 stars 3 forks source link

Layer Switcher Control with Draw Plugin #86

Open Martenz opened 2 weeks ago

Martenz commented 2 weeks ago

When using the Draw plugin in combination with the Layer Switch control it would be handy to have the possibility to add the layer of drawn features as a layer or separated layers (one for each element? maybe too much). In this way it would be possible to hide or show the feature, for instance when interacting with objects on the map eg:

crazycapivara commented 2 weeks ago

The draw-plugin creates a lot of layers which we need to toggle.

It creates layers for every geometry type, active or inactive, ...

In the developer tools we can check it like this:

// Get all draw layers
_maplibreWidget._map.getLayersOrder().filter(l => l.startsWith("gl-draw"))

// Get all draw polygon layers
_maplibreWidget._map.getLayersOrder().filter(l => l.startsWith("gl-draw-polygon"))

_maplibreWidget._map.setLayoutProperty("gl-draw-polygon-fill-inactive.hot", "visibility", "none")
_maplibreWidget._map.setLayoutProperty("gl-draw-polygon-stroke-inactive.hot", "visibility", "none")

Therefore, I need to add layer groups that can be toggled.