I have a WebMap : WebMap | API Reference | ArcGIS API for JavaScript 4.3
Layers in a WebMap are MapImageLayers that contain SubLayers.
In the WebMap API Reference, it mentions that WebMap.allLayers it's a flat collection of all layers, but not sublayers.
My question is, how can I have a collection of all "effective" layers and sublayers, and not group layers.
Because how am I supposed to find a layer by title/url that is specified in a configuration file in my map?
This is what I've tried :
webmap = new WebMap({
portalItem: { // autocasts as new PortalItem()
id: "5bc9a1fdb2ea4d359f2404cd51a64605"
}
})
.load()
.then(function(instance){
console.log('Map allLayers :', instance.allLayers.toJSON()); //No sublayers
return new MapView({
map: instance,
container: "map"
})
})
.then(function(instance){
console.log('View.map allLayers :',instance.map.allLayers.toJSON()); //Same thing as above
console.log('View allLayerViews :',instance.allLayerViews.toJSON()); //Empty
});
Solved! Go to Solution.
Try Collection.flatten: Collection | API Reference | ArcGIS API for JavaScript 4.3
There's a sample there that looks like it may be just what you're looking for.
Try Collection.flatten: Collection | API Reference | ArcGIS API for JavaScript 4.3
There's a sample there that looks like it may be just what you're looking for.