For develop version 1.2, LayerList has provide a way that can add some Feature layers as a FeatureCollection(FeatureLyaersGroup), I think this function can achieve your goal, but develop version 1.2 will release in early August, if you using this function urgent, you can add some code as follows:
Add addFeatureCollection function to stemapp/jimu.js/LayerInfos/LayerInfos.js:
addFeatureCollection: function(featureLayers, title) {
//var id = this._getUniqueTopLayerInfoId(title);
var id = title;
var featureCollection = {
layers: []
};
// set layer id
array.forEach(featureLayers, function(featureLayer, index) {
featureLayer.id = id + '_' + index;
featureCollection.layers.push({
id: featureLayer.id,
layerObject: featureLayer
});
}, this);
this.map.addLayers(featureLayers);
var newLayerInfo;
try {
newLayerInfo = LayerInfoFactory.getInstance().create({
featureCollection: featureCollection,
title: title || id,
id: id
}, this.map);
newLayerInfo.init();
} catch (err) {
console.warn(err.message);
newLayerInfo = null;
}
if(newLayerInfo) {
this.layerInfos.push(newLayerInfo);
this.update();
this.emit('updated');
}
},
In the stemapp/widgets/LayerList/Widget.js, add comments code to startup() as shown below:
if (this.map.itemId) {
LayerInfos.getInstance(this.map, this.map.itemInfo)
.then(lang.hitch(this, function(operLayerInfos) {
this.operLayerInfos = operLayerInfos;
// ***begin*** added code in startup() of LayerList/widget.js
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");
// ***end*** added code in startup() of LayerList/widget.js
this.showLayers();
//this.bindEvents();
this.own(on(this.operLayerInfos,
'layerInfosChanged',
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;
this.showLayers();
//this.bindEvents();
this.own(on(this.operLayerInfos,
'layerInfosChanged',
lang.hitch(this, this._onLayerInfosChanged)));
dom.setSelectable(this.layersSection, false);
}));
}