Hi Helen,
I was having the same issue as you mentioned and I was able to resolve the issue by using below code.
Issue: When adding multiple ArcGISDynamicMapServiceLayer to the map. The layers in LayerList widget expand only one layer and rest won't expand.
Reason: As Robert mentioned when you are adding multiple layers at the same time, layer nodes are not added.
Solution:
//Create an array to hold all new layers
this.dynamicLayers = [];
//Add all dynamic layer to array
this.dynamicLayers.push(dynamicLayer1);
this.dynamicLayers.push(dynamicLayer2);
this.dynamicLayers.push(dynamicLayer3);
this.dynamicLayers.push(dynamicLayer4);
if (this.dynamicLayers.length > 0) {
//setTimeout is requried for multiple dynamic layer, else layer list node expand issue is there.
setTimeout(lang.hitch(this, function () {
//Use addLayers() to add multiple layers.
this.map.addLayers(this.dynamicLayers);
}), 500);
}
Regards,
Arun E