Layer Toggle Button Widget Version 2.14 - 01/13/2020

199587
178
08-01-2016 09:43 AM
Labels (1)

Layer Toggle Button Widget Version 2.14 - 01/13/2020

This is just a simple widget to toggle a configured layer(s) on and off using a button. The layer(s) can be a whole map service layer or a specific sublayer(s) in a map service. This widget will sync with the LayerList widget. You can add multiple instances of this widget to onscreen place holders or in a widget controller like the Header controller in the Foldable theme.

Live Preview Site

List of the latest enhancements and changes:

  1. Fixed issue with group layers in 2.12 WAB.

List of Previous changes:

  1. Fixed issue with basemap being toggled when exclusive mode is used in 2.12 WAB.
  2. Full support for using this widget in the Launchpad themes Anchorbar controller is now supported.
  3. There is now an exclusive mode for the layer toggle. Meaning that all other layers will be toggled off if the layer is exclusive. Caution should be used when choosing this mode.
  4. There is now a zoom to layers extent option for the layer(s) toggles.
  5. There is now a event that can be listened for when a layer is toggled on. The event name is 'toggleChanged'.
  6. Widget now indicates the toggle state of the layer using the background color of the button.
  7. You can follow the directions in the downloads readMe.txt to set the initial state of the button to be toggled on.
  8. Now the widget support toggling multiple layers.
Labels (1)
Attachments
Comments
JanSarata
Esri Contributor

Hi Robert,

much appreciate. Good luck.

Jan

RobertScheitlin__GISP
MVP Emeritus

Jan,

  Download 2.14 version just released and give it a try.

JanSarata
Esri Contributor

Hi Robert,

it was really quick. I tried and it works fine with my group layers now.

Thank you very much,

Jan Sarata

KeithGerhartz1
Occasional Contributor II
  • I have been unable to get this to work with the Plateau theme. I am able to get to work with other themes such as Billboard. Toggling does not change state. Error in console upon initial toggle:

            WidgetManager.js?wab_dv=2.12:549 fail to open widget LayerToggleButton. TypeError: Cannot read property 'children' of null

  • When using in Billboard, the zoom to extents is not respected.
  • The exclusive option is valuable but creates end user confusion in that toggling back does not restore the map to its previous state. The user would need to manually switch a potentially large number of layers back on. Perhaps the existing state could be saved and restored when toggling back?

Thanks for your efforts.

RobertScheitlin__GISP
MVP Emeritus

Keith,

   OK the next release will have the Plateau theme issue fixed.

The zoom to extent will only work for a feature layer or a full map service that provides the layers fullextent.

The saving the maps state with exclusive mode is used is not something I will be tackling anytime soon (that is a lot of work).

MarioNowak
New Contributor II

Hello Robert Scheitlin, GISP‌ – I use the LayerToggle in a project. I use the widget three times to switch between predefined sets of layers.

I observe the following bug: When I click a certain button, the spinning wheel starts spinning on another button sometimes and does not stop until I click another button. See the following video with the behavior (after the third click):

Do you have an idea what causes this behavior and what could be done to prevent it? I use the latest version of LayerToggle.

RobertScheitlin__GISP
MVP Emeritus

Mario,

   I do not see this on my end...

  1. Are you using a custom or modified theme?
  2. Are you using exclusive mode? And if so on all of the buttons?
  3. Did you rename each widget (i.e. give each instance a specific name when configuring the widget)? The tool tip will show a unique name when you hover over the button.
MarioNowak
New Contributor II

Thanks for the answer 🙂

1. Yes, I am indeed using a slightly modified theme.

2. Yes, I am using exclusive mode, but apparently, I forgot to attach it to one button.

3. Yes, they all have unique names.

At first sight, the proper exclusive mode seems to solve it. I will test it further.

Thanks for the help!

MarioNowak
New Contributor II

It does not solve the problem completely, but it happens less often now. And it seems there is not more than one wrongly spinning icon now (before it could happen that 2 where spinning at the same time).

RobertScheitlin__GISP
MVP Emeritus

Mario,

   As I mentioned I do not see this issue in a OTB theme. So I am not sure I can help.

LSAAssociates
New Contributor II

Brilliant tool! And thanks for all of your help to the Esri user community as a whole!

I did have a question. Is it possible to link one instance of a toggle switch with others? So that if you press down on one of the toggles, it will turn off the other instances of the toggle widgets. This way, only one of the toggles is turn on at any given time.

RobertScheitlin__GISP
MVP Emeritus

My solution for that is the exclusive mode in the widgets settings.

LSAAssociates
New Contributor II

I realized that Eric was having the same issue as myself and your fix worked: https://community.esri.com/thread/247572-multiple-layer-toggle-button-instances-getting-out-of-sync 

Thanks,

Zac

DávidGregor
New Contributor II

Hi Robert,

I would like to toggle between two layers. Is it possible to turn off visibility of a layer while turning on visibility of another layer? 

RobertScheitlin__GISP
MVP Emeritus

David you want to look into this widgets exclusive mode then.

KARIMLABIDI
Occasional Contributor

Hello Robert,

It is possible to reverse the On/Off? On my map, the bus stops are visible by default. When I click on the

widget, it puts Off ,it's normal because the layer is visible by default. I would to know if it's possible te reverse that , for my users ,it will be easier to understand what happens on the click!

Thank you Robert and thank you for all your widgets!!

 

Capture.PNG

RobertScheitlin__GISP
MVP Emeritus

@KARIMLABIDI 

You control the initial layer visibility state in your web map that WAB is using. The widget does not control that.

KARIMLABIDI
Occasional Contributor

Yes I know that but the "on/off" is a litlle bit confusing for my users. Do you know if it is possible to change these names as I want?

RobertScheitlin__GISP
MVP Emeritus

@KARIMLABIDI 

OK now I understand your issue.

You can follow the directions in the downloads readMe.txt to set the initial state of the button to be toggled on

RobertHendrickson_MGY
New Contributor II

Is there a way to include the basemaps in this widget? I want to be able to have the aerial imagery basemap for one toggle but the topographic basemap for another toggle.

 

RobertScheitlin__GISP
MVP Emeritus

@RobertHendrickson_MGY 

Nope this widget is only for operational layers in the map not basemaps. There is no basemap toggle widget out there  for WAB.

AndrewKock
New Contributor

Hey Robert,

Do you think it would be possible to leverage bookmarks as the zoom-to option instead of the layer extents?  

Christine_Homuth
New Contributor

Hi Robert,

My apologies if this has already been answered, but I'm wondering if it's possible to change the size and style of the buttons used to toggle between layers or use a text label instead of an icon? 

Thanks!

RobertScheitlin__GISP
MVP Emeritus

@Christine_Homuth I am sure it can be done. But is not something very easy or in my plans. The issue is that you are wanting to change the WAB core component "Widget Placeholder" and that has nothing to do with this widget.

sbednar
New Contributor

Hi Robert. Thank you for all of the work on this widget. 

We are in the process of migrating our apps to a new machine running 10.9.1. 

So far I have not been able to get the widget to work as an extension or in web app builder developer addition. Will this widget be receiving a 2.21 update?

RobertScheitlin__GISP
MVP Emeritus

@sbednar Are there any error shown in the browsers web console when attempting to add/use this widget?

sbednar
New Contributor

@RobertScheitlin__GISP 

These are the errors I get when I try to toggle on and off:

fail to startup widget LayerToggleButton. TypeError: Cannot read properties of null (reading 'tooltipDialog')

fail to open widget LayerToggleButton. TypeError: Cannot read properties of null (reading 'iconItemNode')

fail to close widget LayerToggleButton. TypeError: Cannot read properties of null (reading 'iconItemNode')

 

 

BrandonKrejckant
New Contributor II

Hello, I cannot see the widget as an available widget in Developer edition 2.21. I downloaded, extracted, copied to my widget folder in web appbuilder folder location.

Version history
Last update:
‎08-01-2016 09:43 AM
Updated by: