Hi, I wanted to know if there is a way of creating a group layer hierarchy for individual feature layers in a webmap and display them in a layer list widget for a web app created using ArcGIS Javascript API 4.15 .i.e. grouping individual feature layers into group layer. Converting :-
-Layer1
-Layer 2
-Layer3
-Layer4
into
-GroupLayer1
-Layer 1
-Layer 2
-GroupLayer2
-Layer3
-Layer4
I did try using one of the code samples provided for creating group layers in the Javascript API reference, GroupLayer | ArcGIS API for JavaScript 4.15, Sample-GroupLayer with LayerList widget. https://codepen.io/pen?&editable=true&editors=100. Replaced the mapserver url with feature service urls and used a FeatureLayer constructor. However this fails with the following error in the browser console.
Uncaught (in promise) TypeError: b.load is not a function
at Object.d._createLayerView (dojo.js:2027)
at Array.forEach (<anonymous>)
at Object.c.forEach (dojo.js:595)
at a.d._doWork [as callback] (dojo.js:2023)
at g (dojo.js:418)
at dojo.js:422
I have attached a .html file showing the code that I am using for this task. The same code works for MapImage Layers but fails when using Feature Service layers.