Layer List update based on Toggle Layer Widget

1151
3
03-04-2021 03:48 PM
RandallClark_CSUF
New Contributor II

Is there a way to have the layer list widget update based on what is toggled on and off using the toggle layer widget?

Background:

Im exploring using the toggle layer widget  to create a campus map for utilities. i would like yo have a layer toggle for each utility plan, water, gas, power, sewer, etc. However while the toggle layer widget is great for turning on an off layer for each plan currently the layer list widget doesnt update, so even tho the layer widget for say power plan is turned on, all the layers still show up on the layer list widget and i want just the layers for the power plan on.

Thank you.

 

0 Kudos
3 Replies
KafilBaig
New Contributor III

Hi RandallClark,

For LayerList Widget to achieve the requirement you need you have to modify the LayerListView.js

You need to maintain a flag for each layer and pass that to drawListNode function.

for example in my case i have done like below hope that helps for you.

I am passing window.sessionStorage to this function.The values would be 0 and 1.

if(window.sessionStorage.getItem('PrivilageParam') !== ''){

var sessionParams;

sessionParams = window.sessionStorage.getItem('PrivilageParam') ;

var Layer1 = "Layer1_123";

var Layer2 = "Layer2_456";

var paramOutput = [];

if (sessionparam != "" && sessionparam != null){

var sNumber = sessionparam.tostring();

for (var i=0, len=sNumber.length; i < len; i += 1){

paramOutput.push(+sNumber.charAt(i));

}

var strLayer1;

var strLayer2;

strLayer1 = paramOutput[0];

strLayer2 = paramOutput[1];

 

if (strLayer1  ! =  1) {

     if(layerInfo.id ==Layer1){

          layerInfo._visible = false;

         return;

    }

}

 

if (strLayer2  ! =  1) {

     if(layerInfo.id ==Layer2){

          layerInfo._visible = false;

         return;

    }

}

 

}

 

Hope this helps.

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Randall,

   If you look at the live preview site for this widget you will see that there is no issue at all with the Layer List widget updating based on the layers toggled state... So I am not sure what issue you are encountering.

0 Kudos
RandallClark_CSUF
New Contributor II

Good morning Robert, Thank you for the response and i apologize for my late response. So i think i may be unclear in what i was asking.

What I am trying to do have only layers that are toggled on and off show up in the layer list.


For example, in image 1, nothing is toggled and everything shows in the layer list. in image two the Basement or B is toggled and those layers turn on but everything else is showing up, in image  three the first floor or 1 is toggled and those layers turn on but everything else is still showing up,

What i would like is something like image four (edited) where Basement or B is toggled and those layers are turned on and they are the only ones visible.

Thank you

0 Kudos