Group a collection of layers together and toggle their visibility as a group.
Group layers communicate to the user that layers are related and can be managed together.
In a land development project, you might group layers according to the phase of development.
The layers in the map will be displayed in a format similar to a table of contents. Toggle the checkbox next to a layer's name to change its visibility. Turning a group layer's visibility off will override the visibility of its child layers.
- Create an empty
GroupLayer
. - Add a child layer to the group layer's layers collection.
- To build the table of contents:
- Add the layer's name and a checkbox/switch to the UI.
- If the layer is a group layer, repeat the process for any children.
- To toggle the visibility of the group, change the group layer's visibility property.
- GroupLayer
The full extent of a group layer may change when child layers are added/removed. Group layers do not have a spatial reference, but the full extent will have the spatial reference of the first child layer.
Group layers can be saved to web scenes. In web maps, group layers will be flattened in the web map's operational layers.
Layers, group layer