Editing LayerList widget to include multiple Groups/Divs of layers

10958
12
07-20-2015 11:30 PM
HumzaAkhtar
Occasional Contributor II

How can one go about editing Layerlist widget UI so that multiple layers can be organized in different Divs with different titles. Forexample I wish to add 5 layers relating to Volcanos and 5 layers for Earthquakes in two different divs in the layerlistview.

12 Replies
Mehretab
Occasional Contributor II

 Basically I wanted to organize my layers in layerlistwidget in categories, like none responsive text in between different category as in the original question.  My question here is, is  there a way to do so without the need to group them in ArcMap.

 
            // ***begin*** added code in startup() of LayerList/widget.js 
               // First group          
            var featureLayer1 = new esri.layers.FeatureLayer("http://sampleserver6.arcgisonline.com/arcgis/rest/services/NapervilleShelters/FeatureServer/0");  
            featureLayer1.title = "featureLayer1";  
            var featureLayer2 = new esri.layers.FeatureLayer("http://sampleserver5.arcgisonline.com/arcgis/rest/services/Energy/Geology/FeatureServer/6");  
            featureLayer2.title = "featureLayer2";  
            var featureLayers = [featureLayer1, featureLayer2];  
            this.operLayerInfos.addFeatureCollection(featureLayers, "myGroupLayes");
               // Second group
               var featureLayer3 = new esri.layers.FeatureLayer("http://sampleserver6.arcgisonline.com/arcgis/rest/services/NapervilleShelters/FeatureServer/0");  
            featureLayer3.title = "featureLayer3";  
            var featureLayer4 = new esri.layers.FeatureLayer("http://sampleserver5.arcgisonline.com/arcgis/rest/services/Energy/Geology/FeatureServer/6");  
            featureLayer4.title = "featureLayer4";  
            var featureLayersSecond = [featureLayer3, featureLayer4];  
            this.operLayerInfos.addFeatureCollection(featureLayersSecond, "myGroupLayes2");               
            // ***end*** added code in startup() of LayerList/widget.js  
  /**

I also experimented the the feature collection code above in my layerlistwidget startup function(see the code ) but the title of the groups ("myGroupLayes" and " myGroupLayes2") are not visible in the layerlistwidget. Is it supposed to behave as in the graph or I am missing something.  does it support dynamic layers too?

Thanks in advance

NathanHeickLACSD
Occasional Contributor III

Hi Xiaodong,

Does this code still apply to WAB Developer Edition 2.16?  Does the group layer behave like a regular layer and have a check box to turn it on and off?

Thanks,
Nathan

0 Kudos
GilbertoMatos
Occasional Contributor II


Hello!

I did exactly as you suggested. I was able to mount the layers widget with the groups and my layers within those groups. However, I have some problems, if you can give me a tip, I thank you.

1) I created a map in the portal, only with the topographic map, that is, without layers. I added the layers manually as per your hint, the problem is that the marked layers are not appearing in the caption widget.

2) I need, when the user clicks the checkbox of the group, the children checkboxes, referring to the layers, are all marked, the same is true, if a child checkbox is marked, the parent checkbox is also marked. The same is true, so if all child checkboxes are unchecked, the parent (group) checkbox should be unchecked, and if the parent checkbox is cleared, all children should be cleared.

Any help will be very useful. Sorry for weak English, but I'm Brazilian.

Thank you!
Gilberto.

0 Kudos