Switch on individual layers of a map with a button

2159
8
10-26-2021 05:14 AM
Labels (1)
ksm-hh
by
New Contributor

Hello all,

I have loaded a web map with different layers into Experience Builder to create a WebApp. In this web app, individual layers of the web map should be able to be switched on and off with a button or a switch.

Is this possible and do you have any tips on how I can implement this?

Many greetings

8 Replies
GavinRehkemper
Esri Contributor

Hi, when adding the map widget to your Experience, there is an option to enable the "Layers" tool which will allow the end user of the app to toggle visibility of layers.

GavinRehkemper_0-1635434869457.png

exb-vid.gif

 

BrandonGuo
Occasional Contributor

It's different with a button that quickly turns on/off a layer. If a map has multiple layers, users might want a quick button to turn on a frequently used layer. 

blairtinker
New Contributor II

Out of curiosity did you figure out a way to do this.  I sort of have a hacked method using the filter widget but it's not pretty.  The people we are making the map for really don't like the layer widget, they want easy to click buttons.

BAdejumo
New Contributor II

Hi, 

I tried this hack method but didn't work. How did you do it?

0 Kudos
MargrietdePender
New Contributor II

After adding the layers widget to the map you can activate the option Toggle layer visibility.

With that option you can also activate the new option Use tick boxes:

MargrietdePender_0-1703141505458.png

Then users get on or off switches per layer:

MargrietdePender_1-1703141637464.png

 

This is much understandable for the users.

 

0 Kudos
HalleyGrundy
New Contributor

I am also interested in this - especially if you can create a button that will turn a group of layers on/off. 
@blairtinker, how did you do this with the filter widget? 

blairtinker
New Contributor II

Holy cow this is really old and am just seeing this now- sorry.  I went back to see how I accomplished this and couldn't actually find the application where it was implemented.  We eventually went a different direction so it just went away.  If I recall it was setting up filters that would filter everything/nothing when enabled so instead of actually turning off/on the layers it was really filtering all the features.  I know there are other posts about layer widgets and whatnot but people still seem to want big ol' buttons to turn things on and off.

0 Kudos
MargrietdePender
New Contributor II

Im not sure if the question is still active, but you can add the Widget Map Layers.

You can connect this Widget to Interact with the map widget (choose the correct one).

It also has an option 'Toggle layer visibility' if you switch it on, you have an additional option to use tick boxes.

Now you users of the app can easily switch layers on and/or off.

0 Kudos