Is there a way to add a checkbox next to the layer in the legend widget to turn layers on/off?

4042
6
Jump to solution
05-01-2015 06:47 AM
ChrisSergent
Regular Contributor III

I would like for my users to be able to turn layers on and off so they can see just street signs or supports. I have tried using this widget, but it does not work: http://www.arcgis.com/home/item.html?id=9b6280a6bfb0430f8d1ebc969276b109http://Is there a way to add a checkbox next to the layer in the legend widget to turn layers on/off...

My code for starting the legend is the following:

app.legend = new Legend({

            map: app.map,

            layerInfos: [{

                title: app.supportLayer.name,

                layer: app.supportLayer

            }, {

                title: app.signLayer.name,

                layer: app.signLayer

            }]

        }, "legend");

        app.legend.startup();

0 Kudos
1 Solution

Accepted Solutions
KenBuja
MVP Esteemed Contributor

I used the "default.html" file and it appears to show all the layers in your services. The only edit was to remove the proxy configuration. Which layers are missing?default.png

View solution in original post

6 Replies
KenBuja
MVP Esteemed Contributor

How do you mean that widget doesn't work?What are the issues that you're having? I've used it in many applications without any problem.

There are some other TOC widgets, like this or this​, with others out there on GitHub also.

ChrisSergent
Regular Contributor III

Here is the file I uploaded that doesn't work. It kind of works, but does not show all layers.

https://community.esri.com/docs/DOC-5792

0 Kudos
KenBuja
MVP Esteemed Contributor

I used the "default.html" file and it appears to show all the layers in your services. The only edit was to remove the proxy configuration. Which layers are missing?default.png

ChrisSergent
Regular Contributor III

I tried it and I set always use proxy to false. There appears to be a delay before it populates, but it does populate. Thanks @Ken_Buja. I'll try to add it to my application.

0 Kudos
RichardMoussopo
Occasional Contributor III

kenbujais right. I also use this widget a lot and it's now updated as well.

ChrisSergent
Regular Contributor III

It's been updated? When was that? I might want to try out the update.

0 Kudos