Grouping Dynamic Map Service in WAB LayerlistWidget

403
4
10-20-2017 05:15 AM
Mehretab
Occasional Contributor

I am trying to organize my layers in the layerlistwidget based on categories, like none responsive text in between different category as in this question. My question here is, is  there a way to do so without the need to group them in ArcMap? 

I also experimented the the add feature collection method as in the code below in my layerlistwidget startup function(see the code ) but the groups ("myGroupLayes" and " myGroupLayes2") are not visible in the layerlistwidget, instead all layers are listed in a flat hierarchy (see the graph below).

// ***begin*** added code in startup() of LayerList/widget.js 
               // First group         
            var featureLayer1 = new esri.layers.FeatureLayer("http://Feature layer URL"); 
            featureLayer1.title = "featureLayer1"; 
            var featureLayer2 = new esri.layers.FeatureLayer("http://Feature layer URL"); 
            featureLayer2.title = "featureLayer2"; 
            var featureLayers = [featureLayer1, featureLayer2]; 
            this.operLayerInfos.addFeatureCollection(featureLayers, "myGroupLayes");
               // Second group
               var featureLayer3 = new esri.layers.FeatureLayer("http://Feature layer URL"); 
            featureLayer3.title = "featureLayer3"; 
            var featureLayer4 = new esri.layers.FeatureLayer("http://Feature layer URL"); 
            featureLayer4.title = "featureLayer4"; 
            var featureLayersSecond = [featureLayer3, featureLayer4]; 
            this.operLayerInfos.addFeatureCollection(featureLayersSecond, "myGroupLayes2");              
            // ***end*** added code in startup() of LayerList/widget.js 
  /**‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

I also tried to group feature layer that are already part of the web map using the solution provided by @Robert Scheitlin, GISP in this thread but with no success. Am I missing something obvious. Also does  the add FeatureCollection support dynamic layers too? Or do we have another means to Group dynamic services as in the case of Feature layers?

For more information I am using WAB 2.6 and I also tried the code in WAB 2.2.

4 Replies
DavidCedena
New Contributor

I have the same problem. Can someone help us? Thanxu

0 Kudos
RobertScheitlin__GISP
MVP Esteemed Contributor

This has been asked MANY times before and the response is still the same it is not something that can be done easily and no developer has taken the excessive time to do this as the benefits are minimal when you consider that all a person has to do is group those layer in the Map Service before publishing.

Mehretab
Occasional Contributor

Thaks Robert.

Yes I got you on the grouping of a dynamic map service  part but the code to group feature layers using the FeatureCollection is not grouping my feature layers too. I provided above the code and also how my layers  look like  in my Layerlist widget. I expected my feature layers to be under two groups namely  myGroupLayes and myGroupLayes2). I am missing something there?

0 Kudos
RobertScheitlin__GISP
MVP Esteemed Contributor

That thread was over two years ago and I am not sure that it even works now in current WAB releases.

0 Kudos