so I'm using the JavaScript API to customize an ArcGIS web app and I need to take feature layers and group them in the layer list widget. Here's the code I have that does that (in the widget.js file under the LayerList folder): `

  if (this.map.itemId) {  
      LayerInfos.getInstance(this.map, this.map.itemInfo)  
      .then(lang.hitch(this, function(operLayerInfos) {  
        this.operLayerInfos = operLayerInfos;  

        //create feature collections (groups) from feature layers

        var firstFloorLabels = new esri.layers.FeatureLayer("http://services.arcgis.com/2DbqGRRQS9wbBetw/arcgis/rest/services/Pv03_Labels/FeatureServer/0");            
            firstFloorLabels.title = "1st Floor Labels";

        var firstFloorRooms = new esri.layers.FeatureLayer("http://services.arcgis.com/2DbqGRRQS9wbBetw/arcgis/rest/services/SM_prototype_2_1/FeatureServer/0");
            firstFloorRooms.title = "1st Floor Rooms";  
        var firstFloorLayers = [firstFloorLabels, firstFloorRooms]; 
        this.operLayerInfos.addFeatureCollection(firstFloorLayers, "1st Floor"); 

        var secondFloorLabels = new esri.layers.FeatureLayer("http://services.arcgis.com/2DbqGRRQS9wbBetw/arcgis/rest/services/Pv03_Labels/FeatureServer/0");  
            secondFloorLabels.title = "2nd Floor Labels";
        var secondFloorRooms = new esri.layers.FeatureLayer("http://services.arcgis.com/2DbqGRRQS9wbBetw/arcgis/rest/services/SM_prototype_2_1/FeatureServer/0");
            secondFloorRooms.title = "2nd Floor Rooms";                
        var secondFloorLayers = [secondFloorLabels, secondFloorRooms];               
        this.operLayerInfos.addFeatureCollection(secondFloorLayers, "2nd Floor");                             

        var thirdFloorLabels = new esri.layers.FeatureLayer("http://services.arcgis.com/2DbqGRRQS9wbBetw/arcgis/rest/services/Pv03_Labels/FeatureServer/0");  
            thirdFloorLabels.title = "3rd Floor Labels";              
        var thirdFloorRooms = new esri.layers.FeatureLayer("http://services.arcgis.com/2DbqGRRQS9wbBetw/arcgis/rest/services/SM_prototype_2_1/FeatureServer/0");
            thirdFloorRooms.title = "3rd Floor Rooms";                
        var thirdFloorLayers = [thirdFloorLabels, thirdFloorRooms];                
        this.operLayerInfos.addFeatureCollection(thirdFloorLayers, "3rd Floor");  

                    lang.hitch(this, this._onLayerInfosChanged)));  
        dom.setSelectable(this.layersSection, false);  
    } else {  
      var itemInfo = this._obtainMapLayers();  
      LayerInfos.getInstance(this.map, itemInfo)  
      .then(lang.hitch(this, function(operLayerInfos) {  
        this.operLayerInfos = operLayerInfos;  
                    lang.hitch(this, this._onLayerInfosChanged)));  
        dom.setSelectable(this.layersSection, false);  
  // end of code to group layers  


I can do this through the addFeatureCollection method, but when I create new groups, the feature layers in the groups don't pull in their styles and symbology. Another issue is that when I take my original feature layers and then group them into feature collections, the layer list widget shows both the grouped feature collections, and the original feature layers. Here's what my app is looking like with the code as is.

Here's an ungrouped feature layer that's pulling in styles correctly: enter image description here

And here's a grouped feature collection layer that isn't pulling in it's styles: enter image description here

Does anyone know how I can get the styles for my feature layers and have the layer list widget not display the individual, ungrouped feature layers, but only the feature collections?

  • Is this a custom javascript app? if so, how are you able to modify your widget.js? Are you deploying the widget locally? – user25976 Jan 27 '17 at 21:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.