Select to view content in your preferred language

LayerList TOC Hide Children

2737
1
05-14-2011 12:56 AM
SchoppMatthieu
New Contributor III
Arc Server 10 Flexviewer 2.3.1

Hello,

I'm using the Table Of Content implemented by Robert Scheitlin.

In my mapservices , I have some "groupLayers" that contain duplicated data with different symbology at different scale, all the items whithin these GroupLayers are turned on.

The users just need to turn the GroupLayer on or off to see the data and it's not relevant for them to be able to dropdown these "groupLayer" and see the content.

What I'd like to do is to implement a function that hide the groupLayer content in the TOC. I'd like to be able to define which grouplayers' children  I want to hide in the Table of Content config.xml.

for example: this is my MapService:

//Server/ArcGIS/rest/services/MyMapService/MapServer
- Layer (1)
- Layer (2) (GroupLayer)      
______- Layer(3)
______- Layer(4)
- Layer (5)

I'd like to be able to add in the TOC config.xml something like:
<hideChildren> //Server/ArcGIS/rest/services/MyMapService/MapServer/2 </hideChildren>

In the TOC.as :
I tried to use "_tocRoots.removeItemAt"
I saw that "unregisterMapLayer" can hide a MapServices and I tried to recreate the same thing for the tocItem.children but I struggle.

Some help would be very appreciated.

Matt
Tags (2)
0 Kudos
1 Reply
SchoppMatthieu
New Contributor III
I tried to get my "hideChildren" function working.

So far I managed to hide the children of a MapService (Layer) but I didn't find a way of hiding the children of a particular GroupLayer in the MapService.

To hide the Children of the MapService:

In TOCWidget.mxml:

var lyr:Layer = ViewerContainer.getInstance().mapManager.map.getLayer("myLayer");
toc.hideChildren(lyr);

In TOC.as:

public function hideChildren(layer:Layer):void{
  
var tocItem:TocMapLayerItem;
 
if(_mapLayerItems[layer]) {
tocItem = _mapLayerItems[layer];
} else {
tocItem = new TocMapLayerItem(layer,_labelFunction,_isMapServiceOnly);
_mapLayerItems[layer] = tocItem;
}  
  
if (tocItem.children){
tocItem.children = null;
   
if (_tocRoots)
{
for (var i:int = _tocRoots.length - 1; i >= 0; i--)
{
if (TocItem(_tocRoots).parent === tocItem.parent)
{
_tocRoots.removeItemAt(i);
}
}
}
}
}

So it keeps the TopLevel of the tree visible and hide the children in the Table Of Content, if the Children are turned on, they are still visible on the map (that's what I want) they are just "hidden" in the TOC tree.

It's a start but it's not quite what I want to achieve. I'd like to hide the Children of a specific GroupLayer within the MapService and not all the childrens of the MapServices.

Any help ?
Thanks Matt
0 Kudos