The dynamic layer group automatically creates a list of all the user defined layers in the map. You can limit the layers that the dynamic layer group lists, however you can only have one dynamic layer list per layer control. For your scenario, you would most likely have to specify the layers items explicitly in the layer control. You can then create groups of layers, however layer groups can't have sub-groupings, so you can't go multiple groupings deep. You can however make the groups radio or check box lists which may help depending on your scenario.
Azure maps group layers in layer control
Brenda Olsen
21
Reputation points
Hi all, I have an Azure map with many layers. Is it possible to group them, preferably tree-wise, and add those groups to the layer control?
//Create the layer control.
layerControl = new atlas.control.LayerControl({
//title: 'Layers',
//Attach the legend control.
legendControl: legend,
dynamicLayerGroup: {
groupTitle: 'Group 1',
layout: 'checkbox',
}
});
Accepted answer
-
rbrundritt 15,386 Reputation points Microsoft Employee
2022-08-08T14:51:14.153+00:00
1 additional answer
Sort by: Most helpful
-
Brenda Olsen 21 Reputation points
2022-08-09T07:52:59.147+00:00 thank you. I made it work like this now:
layerControl = new atlas.control.LayerControl({ legendControl: legend, layerGroups: [ { layout: 'checkbox', groupTitle: 'groupTitle1', layers: ['layer1', 'layer2'], items: [{ label: 'layerTitle1', layout: 'checkbox', enabledStyle: { visible: true }, disabledStyle: { visible: false } }, { label: 'layerTitle2', layout: 'checkbox', enabledStyle: { visible: true }, disabledStyle: { visible: false } } ] }, { layout: 'checkbox', groupTitle: 'group Title 2', layers: ['layer3', 'layer4'], items: [{ label: 'layerTitle3', layout: 'checkbox', enabledStyle: { visible: true }, disabledStyle: { visible: false } }, { label: 'layerTitle4', layout: 'checkbox', enabledStyle: { visible: true }, disabledStyle: { visible: false } } ] } ] });