Select to view content in your preferred language

Getting Layers within a GroupLayer that contains other GroupLayers

3270
3
Jump to solution
10-17-2014 04:31 AM
Labels (1)
ChristopherMcCafferty
New Contributor

Hi Guys,

I was wondering if someone can help me out. I am trying to search for a certain layer using the ID property but my map contains many different types of Layers.

Here is a small diagram I have quickly made up to help explain what I am trying to do.

GroupLayerOne

     ChildLayerOne

     ChildLayerTwo

GroupLayerTwo

     ChildGroupLayerOne

          LayerOne

          LayerTwo

          LayerThree

     ChildLayerThree

GraphicsLayer

I am trying to think of a easy way of searching through all these layers to find the one I want. I been toying around with trying to do it myself but I was wondering if the ESRI SDK had some functionailty that would make this easier.

Any advice/help appericated guys.

Thanks,

Chris

0 Kudos
1 Solution

Accepted Solutions
DominiqueBroux
Esri Frequent Contributor

You can use EnumerateAllLayers or EnumerateLeaves defined on FeatureCollection.

Something like:

foreach(var layer in MyMapView.Map.Layers.EnumerateLeaves())

.....

View solution in original post

0 Kudos
3 Replies
DominiqueBroux
Esri Frequent Contributor

You can use EnumerateAllLayers or EnumerateLeaves defined on FeatureCollection.

Something like:

foreach(var layer in MyMapView.Map.Layers.EnumerateLeaves())

.....

0 Kudos
ChristopherMcCafferty
New Contributor

Thanks for the reply Dom,

For some reason I cannot access this function via the Layers property.

Its a function thats part of the GroupLayerBase class.

I have tried something like this:

var trees = GroupLayerBase.EnumerateLeaves(_map.Layers);

But the tree variable has null layers after its called this.

0 Kudos
ChristopherMcCafferty
New Contributor

Scratch that last comment Dom,

It seems to be working as it should.

Thanks!!!

0 Kudos