My case is the following: I have a custom widget, which displays tree of Layers of a WMS and allows users to select Layers to show on the map. I'd like to use WMSLayer to both get the full list of WMS Layers for the widget and to control visible on the map WMS Layers.
But I don't understand how to do that in the best way because:
I have to use a workaround:
But this approach seems a little bit hacky to me. Is there a better way to do it?