Upper level grouping for layer list widget

830
0
01-27-2017 01:59 PM
Quynh_NhuMai
New Contributor III

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

0 Kudos
0 Replies