Group Visibility when SubLayer is Turned on

3966
6
04-03-2015 04:16 AM
denverweston
New Contributor III

Good Morning,

Can anyone point me to the location where I can add code that if a sublayer is turned on the Group Layer is also turned on in the LayerList?

Thanks

0 Kudos
6 Replies
RyanStrain
New Contributor III

My solution was to have all the group layers on from the start, whether a sublayer is turned on, or not. Then the user doesn't have to worry about it.

0 Kudos
StanMcShinsky
Occasional Contributor III

I think this would be a helpful enhancement as well. Not only for WAB but for AGOL too.

0 Kudos
RyanStrain
New Contributor III

Speaking of enhancements, I would like the ability to set a group layer as expanded showing the sublayers on startup. Or if someone knows how to code this? For some of my users, they are only aware of the checkbox, but take awhile to realize clicking on the group name itself will expand the group.

0 Kudos
denverweston
New Contributor III

Agree that this should be in WAB and AGOL.  Sometimes external map services have a lot of group layers.

0 Kudos
denverweston
New Contributor III

Here is where I'm starting to look at this possibility in the map service layer info.

_setTopLayerVisible: function(visible) {

      this.originOperLayer.layerObject.setVisibility(visible);

      this._visible = visible;

    },

0 Kudos
deleted-user-0W0-oLHxDjCX
New Contributor III

I am doing the inverse (after select the main group all child are set visible to true. It works but the TOC and the map are not updated until the application refresh.

See my code:

if (evt.ctrlKey) {
   if (ckSelect.checked && layerInfo.newSubLayers.length > 0) {
      for (var i = 0; i < layerInfo.newSubLayers.length; i++) {
         var layer = layerInfo.newSubLayers;
         layer._visible = true;
      }
   }
}

Could someone give me some idea?

0 Kudos