Select to view content in your preferred language

Collection .flatten method

61
2
Thursday
D_Atkins
Occasional Contributor

According to the documentation for .flatten(), the function should operate recursively on the collection.  We notice, however, that working with a MapImageLayer, that flatten() does not appear to check for sublayers within sublayers.

It should be easy enough to write our own recursive check for 'sublayers of sublayers' but wanted to ask the Community if there was anything we were missing here that might streamline the coding!?

           

             

0 Kudos
2 Replies
JeffreyThompson2
MVP Frequent Contributor

Does the allSublayers property of the MapImageLayer work for you?

https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-MapImageLayer.html#allSubl...

GIS Developer
City of Arlington, Texas
D_Atkins
Occasional Contributor

Sure, that's a neat one!   Easy enough to catch the 'map-image' layer types from the layer collection from map.view, then use the .allSublayers with that...

Not sure I'm seeing a clean approach for discerning the hierarchy after the fact.  If we handle the sublayer recursion ourselves, at least we know 'on-the-spot' if a sublayer has sublayers, and can trace how many recursions (how many steps into the hierarchy) we are.

With the .allSublayers property, we can at least still check if a sublayer in the flat collection has sublayers (or not...), which may be enough to pull out the principal feature layers... always more than one way to go, I suppose!



  

0 Kudos