I am working with a series of Leaflet FeatureGroups, each made up of GeoJSON layers. These FeatureGroups have similar concepts but need to be kept separate for control purposes. I also require the ability to toggle all FeatureGroups on and off simultaneously. Is there a method to achieve this?
Upon reviewing the documentation, I did not come across any event that triggers when a FeatureGroup is toggled. There seems to be no documented way of grouping FeatureGroups into a superGroup either.
To provide a visual representation of the process: GeoJSON data is converted into layers in Leaflet. These layers represent various administrative boundaries such as States and Counties. Each layer is placed in a specific FeatureGroup based on its category (e.g., Arkansas and New York in State FeatureGroup, Ford and Lincoln counties in County FeatureGroup). This setup allows me to manage opacity and styling for each FeatureGroup individually. However, I still require a method to toggle all groups collectively. While Leaflet permits toggling FeatureGroups individually, it lacks a super set function for this purpose.
Are there any suggestions on how to accomplish this task?
New revised question:
Which event triggers when switching a LayerGroup on and off? Is there a way to interact with this event?