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.
List of the latest enhancements and changes:
List of Previous changes:
Hi Robert,
much appreciate. Good luck.
Jan
Jan,
Download 2.14 version just released and give it a try.
Hi Robert,
it was really quick. I tried and it works fine with my group layers now.
Thank you very much,
Jan Sarata
WidgetManager.js?wab_dv=2.12:549 fail to open widget LayerToggleButton. TypeError: Cannot read property 'children' of null
Thanks for your efforts.
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).
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.
Mario,
I do not see this on my end...
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!
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).
Mario,
As I mentioned I do not see this issue in a OTB theme. So I am not sure I can help.
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.
My solution for that is the exclusive mode in the widgets settings.
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
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?
David you want to look into this widgets exclusive mode then.
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!!
You control the initial layer visibility state in your web map that WAB is using. The widget does not control that.
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?
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
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.
Nope this widget is only for operational layers in the map not basemaps. There is no basemap toggle widget out there for WAB.
Hey Robert,
Do you think it would be possible to leverage bookmarks as the zoom-to option instead of the layer extents?
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!
@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.
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?
@sbednar Are there any error shown in the browsers web console when attempting to add/use this widget?
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')
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.