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