Layer Groups

Layers can be optionally grouped into layer groups. Layers in the same group are displayed together in the legend.

The visibility for all layers in a group can be set at the group level. If the group visibility is turned off then none of the layers in the group will be visible, regardless of their individual visibility settings. If the group visibility is turned on, then individual layers within the group can be made visible or not visible separately.

Layer groups can be nested so a group can contain other groups. This provides a finer level of control for handling layer visibility or legend groups.

The MgMap::GetLayerGroups() method returns an MgLayerGroupCollection object that contains all the layer groups in the map.

Each layer group in a map must have a unique name, even if it is nested within another group.

#### Topics in this section

- Base Layer Groups