Developing a Table of Contents to turn on\off layers... anyone try this?

11863
47
Jump to solution
04-10-2015 09:01 AM
MikeCrook
New Contributor III

I'm developing a Table of Content to turn on\off layers on map using javascript \ dojo-AMD sdk. I found a few places on the internet that shows ways. Nothing that is making complete sense to a newbie. Has anyone done this in a way that makes sense?

Tags (1)
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Emeritus

Mike,

   Have you seen Nliu's TOC? http://www.arcgis.com/home/item.html?id=9b6280a6bfb0430f8d1ebc969276b109

Here is a thread where some one else was have an issue getting it going and then got it figured out

TOC - totally stumped

View solution in original post

47 Replies
RobertScheitlin__GISP
MVP Emeritus

Mike,

   Have you seen Nliu's TOC? http://www.arcgis.com/home/item.html?id=9b6280a6bfb0430f8d1ebc969276b109

Here is a thread where some one else was have an issue getting it going and then got it figured out

TOC - totally stumped

JeffJacobson
Occasional Contributor III

I've been working on a TOC / Layer List control, too: WSDOT-GIS/arcgis-js-layer-list · GitHub

TracySchloss
Frequent Contributor

I feel like most people are using Nilu's TOC.  I thought the instructions for implementing as dojo AMD were pretty straight forward. 

0 Kudos
by Anonymous User
Not applicable

this is why every so often I like to recommend ESRI to please include TOC as a part of the API. Probably something like 75% of people are using Nianwei Liu  ​​'s AGS TOC widget. I'd recommend using that, it's a fantastic widget.  There's nothing wrong with making your own TOC if you want to do something unique but 9 out of 10 times we just need the basic functionality AGS TOC provides.

AGS TOC caveats and notes:  On a recent project I found out ESRI removed the ability to embed tokens in proxies a few API versions back. Thus now AGSTOC now doesn't work with secure services! One reason why ESRI should officially add a TOC in the API.  For this project... I "made" a TOC for the one secure service by creating a checkbox tied to a .show/hide for that layer..and use AGS TOC for the other services, one TOC per Accordion.  (you can have multiple instances of a AGS TOC widget, and for example put one per accordion) Also AGSTOC doesn't work with Annotations. And until recently had problems with legends in secure services (an ESRI staffer was kind enough to provide a workaround)  And when calling ESRI Support one must usually convince them to support AGS TOC widget once they notice that in the code.  In a recent thread Kelly says they are considering adding the WebApp Builder TOC to the API.  This will sure be a great thing!  I am looking forward to it.

0 Kudos
KenBuja
MVP Esteemed Contributor

At this year's Developer Summit, I talked with one of the Javascript specialists about adding a TOC into the API. He talked about some of the issues with modifying the existing WebApp Builder TOC, since that relies on using ArcGIS.com web maps and not directly using services. I described how I was using the AGSTOC with both my own services and with outside services (when I didn't want to show all the layers in a particular service)

In a followup email, I gave him code samples on how I was able to show only a subset of layers in a service and also how I could create a TOC that allowed for both check box and radio button ways of turning on layers. In one case, I have a TOC that has layers that can be turned on independently and layers that can only be turned on one at a time.

denverweston
New Contributor III

Hey Ken,

Is there anyway to turn on all sublayers and turn off all sublayers in the WebApp builder?  I'm trying to do this with my own layers.  Thanks

0 Kudos
MikeCrook
New Contributor III

Thanks for the information. This seems like a good route to take.

0 Kudos
BenFousek
Occasional Contributor III

Mike Crook

You can find my implementation of a layer control included with cmv/cmv-app · GitHub  for inspiration. It can also be used outside of the CMV framework.

by Anonymous User
Not applicable

Ben, that's an awesome website template. Thanks!

0 Kudos