walkermatt / ol-layerswitcher

Layer control for OpenLayers
MIT License
387 stars 176 forks source link

switcher not updated if group visibility changed from code #377

Closed mysiar closed 3 years ago

mysiar commented 3 years ago

I have a case that I build the base map with LayerSwitcher. Later on I create groups and set their visibility depend on the config but LayerSwitcher do not see the visibility in Panel. Is there any way I can hook it to update Switcher based on group visibility ?

mysiar commented 3 years ago

I have a case that I build the base map with LayerSwitcher. Later on I create groups and set their visibility depend on the config but LayerSwitcher do not see the visibility in Panel. Is there any way I can hook it to update Switcher based on group visibility ?

I found out if I add layer to group and set layer visibility to group visibility that LayerSwitcher is updated the way I wanted :)

walkermatt commented 3 years ago

Hi, you can also call the renderPanel method of your instance which should update the layers shown in the panel to match the current state of the map 👍