Select to view content in your preferred language

Question on Enhanced Layer List Widget &  Feature Layer Tips for Layer visibility

2525
6
08-29-2013 08:48 AM
MayJeff
Deactivated User
Currently I use both widgets Enhanced Layer List Widget(http://www.arcgis.com/home/item.html?id=58d9bb5693c94918a3934781d7234d18) & Feature Layer Tips widget (http://www.arcgis.com/home/item.html?id=ce63f1bdd5e64068b9a4fadd2028e379).  I would like to know if you turn a zoning layer off (uncheck the layer) and your feature layer will be turn off with a label name "zoning" on your configuration file.  Otherwise, your zoning layer will be on (check the layer).
Can someone show me where to change to code to perform this task?

Thanks.
Tags (2)
0 Kudos
6 Replies
RobertScheitlin__GISP
MVP Emeritus
May Jeff,

   I am not sure what the eLayerList and the Feature Layer Tips widget have to do with the question about turning the visibility of a particular layer in code?... Can you go into more detial... Are you running into a specific issue that you think is related to these widget?...
0 Kudos
MayJeff
Deactivated User
These widgets all working well.  Thank you for developing it.
I want to see whether able to write a code for additional function that can control a layer visibility on TOC.  For example, if you uncheck layer 1 (turn off layer 1) then layer 2 will be uncheck (turn off) as well. Otherwise show layer 1 & layer 2 on the map.
Hope explain it clearly. 
Thanks.
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
May Jeff,

  That would depend, are layer 1 and 2 sublayers of a  map service or are they whole map services? Basically you  need to get the 'map' object and use getLayer to get the Map Service  (layer) based on the Map Services id and then if layer 1 is the name  of a layer in that map service then you need to set the visibleLayers  property for the ArcGISDynamicMapServiceLayer (i.e. remove the id number  that represents your layer 1 from the  visibleLayers ilist).
0 Kudos
MayJeff
Deactivated User
Layer 1 is a sublayer and layer 2 is my feature layer that I used for my feature tooltip widget.
Can you give me some ideas where to add a function that able to check my layer 1 visibility?  You got a lot on your TOC folder and just not sure where to start writing my condition to the code.  Thank you Robert.
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
May Jeff,

   Is layer 1s parent layer an ArcGISDynamicMapServiceLayer? What is its name? Basically in the TOC.as in the registerMapLayer function you would have an if statement that checks if the layer being registered is the parent layer of layer 1 and if so then add an event listener that listens for the visibleLayers property to change and run a function that will search the iList for Layer 1s ID (the number) and if it is not part of the iList then turn off Layer 2. I don't really have time to write a code sample for you.

Here is an example of adding the event listener:
ArcGISDynamicMapServiceLayer(layer).visibleLayers.addEventListener(CollectionEvent.COLLECTION_CHANGE, visibleLayersChangeHandler);
0 Kudos
MayJeff
Deactivated User
Yes, layer 1 is ArcGISDynamicMapServiceLayer and name it "CITYZONING".  I will looks into TOC.as file.  Thanks.
0 Kudos