Select to view content in your preferred language

Dynamic Map Service Sublayer Visibility

2334
3
03-14-2012 10:33 AM
ColterSikora1
Emerging Contributor
Hi All!

I have a multi-layered map service that I would like to deploy as a dynamic layer in Flex.  The trick is that I want the user to only have the ability to turn the entire service on or off (and not individual sublayers).  From the forum threads that are similar to mine, it seems unlikely that I can pull this off, but has anyone tried this?  A map cache is a potential back-up option, but the dynamic layer would be easier to update! 

Thanks for your help in advance!

Colter
Tags (2)
0 Kudos
3 Replies
RobertScheitlin__GISP
MVP Emeritus
Colter,

   The only option I can think of is for you to modify the code in the com/esri/viewer/components/toc/tocClasses/TocMapLayerItem.as
prevent the createChildren function from occurring if the layer name equaled your layer.

Don't forget to click the Mark as answer check and to click the top arrow (promote) as shown below:
0 Kudos
ColterSikora1
Emerging Contributor
Thanks Robert for pointing me in this direction!  I got to a point in the .as code where I can stop a sublayer from displaying completely.  However, I still want the data to display if the root layer is activated.  This is the code I am working with at the moment:

  if (layerInfos)
  {
   var rootLayers:Array = findRootLayers(layerInfos);
   for each (var layerInfo:LayerInfo in rootLayers)
   {
    var name:String = layerInfo.name;
    if (name=='Transportation Projects')
    {
   //  addChild(createTocLayer(this, layerInfo, layerInfos, visibleLayers, layer));
    }
    else
    {
     addChild(createTocLayer(this, layerInfo, layerInfos, visibleLayers, layer));
    }
   }
  }


With the code as-is, the layer Transportation Projects (which is a group layer within a map service) will not display.  I would assume if I can remove the right arguements from the 'addChild' code, I can make the layer continue to display, without allowing the user to drill into the sublayers.  When I attempt to change the 'addChild' code, I get a variety of errors, since I am messing with properties.  Any ideas to work around this?  Thank you for your help!

Colter
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Colter,

   You are getting really deep in the weeds of some very compilated stuff here and I would even have to spend some time examining the paths of the code to figure out if what you want to do is possible (whic likely is). I just don't know the answer right off and don't have the free time to figure this out. I would start by looking at the actual createTocLayer function and maybe prevent the loop from happen for the sublayers.
0 Kudos