Select to view content in your preferred language

(javascript 3.23 API) toggle off sublayers when the main layer is toggled off

997
6
01-31-2018 07:08 AM
by Anonymous User
Not applicable

Using the layerlist widget (3.23 API) how can I cause all sublayers to be toggle off when the main layer is toggled off 

0 Kudos
6 Replies
RobertScheitlin__GISP
MVP Emeritus

Randy,

  Unless I am missing something... When the parent layer is toggled off all its sublayers are toggled off as well.

I just tested this sample to be sure.

https://developers.arcgis.com/javascript/3/sandbox/sandbox.html?sample=widget_layerlist_basic 

0 Kudos
by Anonymous User
Not applicable

But when you turn the main layer off, the sublayers that were active remain

active. I need all of the subLayers to be deselected when the main is

toggled off

On Wed, Jan 31, 2018 at 11:29 AM, Robert Scheitlin, GISP <geonet@esri.com>

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Randy,

   That is not what I am seeing... If I toggle a parent layer off the the visibility of all sublayers are are turned off as well.

0 Kudos
by Anonymous User
Not applicable

Yes...the visibility. but I need the sublayer checkboxes to be toggled off

as well. My code depends on the action of selecting the individual

checkboxes for the sublayers. subLayerIndex returns to null when the

mainlayer is reselected but the sublayer stays visible and the checkbox

remains selected. The user, in this case, would have to deselect the

sublayer and reselect it in order for the code to evaluate properly.

On Wed, Jan 31, 2018 at 11:45 AM, Robert Scheitlin, GISP <geonet@esri.com>

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Randy,

   My suggestion is that you reevaluate your workflow. When a parent checkbox is set to false the you get the layers sublayers and do you code logic on the fact that all the parent layers sublayers are now not visible and do not depend on the checkbox change event for the sub layers. I don't think you want to cause the checkbox to toggle on the sublayers as that mean the user would have to re-check the ones they want to be visible each time they un-check the parent and re-check the parent.

0 Kudos
by Anonymous User
Not applicable

Robert,

Thanks but I am dealing with many image layers and sublayers and reading

pixel values via a mouse pointer. The pixel value must then be evaluated

using identifytask on the rest service layer relevant to the selected

image. I can see no way to identify the image on the map other than it

having been selected. If all sublayer image references are not nullified,

the user will not be sure which image layer is being evaluated. I have

explored a number of different approaches to this problem but I am unable

to conceive of another solution.

On Wed, Jan 31, 2018 at 12:25 PM, Robert Scheitlin, GISP <geonet@esri.com>

0 Kudos