AnsweredAssumed Answered

Multiple Layer Toggle Button instances getting out of sync

Question asked by ericmdg on Feb 3, 2020
Latest reply on Jun 24, 2020 by 109460

I'm using 7 instances of LayerToggleButton (7 separate config files, 1 widget folder).

Our WAB opens with some layers already displaying on the map. The first toggle button says 'off', the rest say 'on' if you hover over them.

 

Our first Toggle Button is the default layers. Push it once, all the layers that were on, get turned off. The layers are now off, the hover text on the icon switched to 'on', all the rest of the Toggle Buttons still say 'On' if hovered over.

You can cycle that same button repeatedly and those cycle like that.

 

But say I click the second Toggle Button? If the layers from the first button were showing, pushing the second button flips to it's layers (good), push it again, its still properly flipping the layers on and off.

But if I start bouncing between these buttons, layers start staying on and off irrespective of whatever they were supposed to be. You can sync them back up again by pressing the same button repeatedly. But they start acting wierd as you go between them. I swear I had at one point a cycle of three button presses: the button's assigned layers, the default layers, and no layers showing, but I think that only happens after you've switched between buttons.

 

I also added some (hacky, non widget oriented) code that syncs the grouped layers on/off checkboxes, but they arent properly in sync with the layers either. Usually they are the opposite of what the layer is displaying (i.e. the layers arent actually visible but the checkboxes are on, hit the toggle button, and those all flip). That code works, but I will probably need to post it on here as a seperate question because it needs to be converted to proper widget oriented syntax (rather than decending up and down an arbitrary set of dom elements). It's just doing like the exact opposite of what it's supposed to be.

 

I feel like this is a simple logic issue but I'm not sure where that issue lies.

Outcomes