AnsweredAssumed Answered

Upper level grouping for layer list widget

Question asked by mai_quynhnhu on Jan 27, 2017

I'm testing out the LayerList javascript widget. Is there any way to group the layers?

 

var layers = [
{
layer: new FeatureLayer("http://ourserver/arcgis/rest/services/ourcommune/commune_base/MapServer/1")
//featureCollection: featureCollection, // required unless layerObject. If the layer is a feature collection, should match AGOL feature collection response and not have a layerObject.
showSubLayers: true, // optional, show sublayers for this layer. Defaults to the widget's 'showSubLayers' property.
showLegend: true, // optional, display a legend for the layer items.
//content: , // optional, custom node to insert content. It appears below the title.
showOpacitySlider: true, // optional, display the opacity slider for layer items.
//button: , // optional, custom button node that will appear within the layer title.
visibility: true, // optionally set the default visibility
id: "Commune_Cadrillage" // optionally set the layer's id
},
{
layer: new FeatureLayer("http://ourserver/arcgis/rest/services/ourcommune/commune_assn/MapServer/3")
//featureCollection: featureCollection, // required unless layerObject. If the layer is a feature collection, should match AGOL feature collection response and not have a layerObject.
showSubLayers: true, // optional, show sublayers for this layer. Defaults to the widget's 'showSubLayers' property.
showLegend: true, // optional, display a legend for the layer items.
//content: , // optional, custom node to insert content. It appears below the title.
showOpacitySlider: true, // optional, display the opacity slider for layer items.
//button: , // optional, custom button node that will appear within the layer title.
visibility: true, // optionally set the default visibility
id: "Commune_Main" // optionally set the layer's id
}
];

var layerList = new LayerList({
map: window.myMap,
showLegend: true,
showSubLayers: true,
showOpacitySlider: true,
layers: layers
},"layerListDom");
layerList.startup();

 

This shows up as:

- Commune_Cadrillage

- Commune_Main

 

How can I get this to be :

- Commune

--Commune_Cadrillage

--Commune_Main

Outcomes