Select to view content in your preferred language

problem with view.map.allLayers?

440
1
03-28-2023 10:53 AM
GaryB
by
Occasional Contributor

I am using a webmap in my mapview.  Once the view is ready (i.e. after view.when()), I do the following to produce the output on the right in the image below:

let layers = view.map.allLayers
console.log("layers.length = ", layers.length)
for (const l of layers){
  console.log(`${l.title} - (${l.type})`)
}
 
For comparison, the table of contents for the webmap that I'm using is shown on the left side of the image below.  The problem I'm having is that the '2020-2029 STIP Points' and the '2020-2029 STIP Lines' layers are not showing up in the output.  In the output the group shows up as a map image but the layers underneath are feature layers.  Could it be because the layers begin with numbers?
 
Capture.JPG
 
   
0 Kudos
1 Reply
UndralBatsukh
Esri Regular Contributor

Hi there, 

https://developers.arcgis.com/javascript/latest/api-reference/esri-Map.html#allLayers - according to the document, allLayers collection contains basemap layersoperational layers and ground layersGroup Layers and their children layers are also part of this collection.

So for MapImageLayer you'd have to use https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-MapImageLayer.html#allSubl... to get its sublayers. Same thing goes for TileLayer.