Select to view content in your preferred language

group layer / sub layer visibility

2921
4
09-08-2010 07:34 AM
TerryGiles
Frequent Contributor
I'm trying to modify the sublayer list example but am having issues as my map service contains group layers.

If the user clicks the checkbox for a sub layer it should only show if the parent (or in my case parent and grandparent) layers are also visible.  While a dynamic layer has the ChildLayers property it has no built in concept of ParentLayer.  I'm getting stuck on how to recurse up the sublayer tree and visibility of parent/grandparent layers - does anyone else have a code snippet on how to do this efficiently?  Thanks, TG
0 Kudos
4 Replies
dotMorten_esri
Esri Notable Contributor
To better understand how the visible layers property works, try and get a feeling for how the REST endpoint works. See
http://services.arcgisonline.com/ArcGIS/SDK/REST/export.html
Look at the "layers" parameter. For each ID you add to the VisibleLayers array, it will get added to the "Show" value.
Ie VisibleLayers = new int[] { 1,2,3 }
will generate: &layers=show:1,2,3
0 Kudos
ChristineZeller
Occasional Contributor
Terry,

Did you make any progress on this?  Can anyone else help.  I'm having the same issue and I took a look at the suggested like that SharpGIS suggested and I still can't grasp it.

Thanks
Christine
0 Kudos
TerryGiles
Frequent Contributor
Hi Christine,

Sorry, I have not made any headway on this - got pulled off of the silverlight project to deal with some issues in our exising .Net ADF application.  I'm hoping to get back to the SL project next week, but not sure how much time I'm going to put into this for now - it sounds like either in version 10 SP1 or a SL toolkit release shortly thereafter a TOC class will be available in the ESRI silverlight toolkit

My issue is that in a mapservice I have grouped layers - say layer 0 is a group and 1 & 2 are child layers in that group.  When a user clicks a checkbox assoicated with layer 2, I need to climb back up the layer tree to see if layer 0 is currently in the visiblelayers property of the dynamic service.  If it's not then 2 should not be added.  Same concept going down the tree - if the user checks the checkbox associated with layer 0 and neither 1 nor 2 are in the VisibleLayers then 0 should not be added to the VisibleLayers .... basically I'm trying to have it work like it does in ArcMap.  If memory serves me correct, the SL API will draw layers 1 & 2 if I add 0 to VisibleLayers even without adding 1 & 2.
0 Kudos
ChristineZeller
Occasional Contributor
Terry,

I'm having the same issue.  I'm using the sublayer list from the interactive SDK and it appears like it isn't honoring the parent/grouping.  When the parent/group check box is checked all layers draw (no matter what).  When the parent/group is unchecked the child layers draw if they are checked.  It seems like it is backwards or something.
0 Kudos