Web App - Layer Display

3501
3
Jump to solution
06-04-2015 12:58 PM
ChrisHolmes
Occasional Contributor III

Hello everyone,

I'm wondering how difficult & what would be involved to customize the layer display list on a web app template. For example the source map service for a web map/app may have 20 layers (a bunch that are there for display but don't need to be displayed in the layers list such as roads, water, rail...), but other layers that I do want to be available in a layers list so that the user can turn them on and off (i.e. building permit, business license...). Is it possible to have the map display all layers but then have the layers list display only the ones I want the user to be able to turn on/off?

Thanks all

Tags (1)
0 Kudos
1 Solution

Accepted Solutions
KellyHutchins
Esri Frequent Contributor

Which template?  Let's say its the Basic Viewer. In that case you'd need to edit the js/TableOfContents.js file to remove the layers you don't want to display. If you look at the TableOfContents.js file you'll see that at line 94 we get an array of layers in the map.  And then starting at line 101 we create a list item for each layer in the array.

So one option would be to loop through the layers in the array that is created at line 94 and add only the layers you want to display to a new array which you could then use to populate the list.

Screen Shot 2015-06-05 at 10.06.41 AM.png

View solution in original post

3 Replies
KellyHutchins
Esri Frequent Contributor

Which template?  Let's say its the Basic Viewer. In that case you'd need to edit the js/TableOfContents.js file to remove the layers you don't want to display. If you look at the TableOfContents.js file you'll see that at line 94 we get an array of layers in the map.  And then starting at line 101 we create a list item for each layer in the array.

So one option would be to loop through the layers in the array that is created at line 94 and add only the layers you want to display to a new array which you could then use to populate the list.

Screen Shot 2015-06-05 at 10.06.41 AM.png

ChrisHolmes
Occasional Contributor III

Thanks Kelly. I've reached out to my colleague to confirm which template they are using and will work from the details you have provided. Have a good weekend!

0 Kudos
ChrisHolmes
Occasional Contributor III

Thanks again Kelly

0 Kudos