[GIS] How to add a Group Layer control to a Table of Contents sample

arcgis-javascript-api

I'm still trying to find the perfect Table of Contents sample for the ArcGIS Server JavaScript API 2.3. My previous question gave some hints but I now have a more specific question regarding checkboxes for layer control.

I need to provide a Table of Contents containing a variety of Tiled, Feature and Dynamic layers, which may be sourced from multiple ArcGIS Server instances. The TOC should allow the user to toggle individual layers on/off, and toggle multiple layers on/off simultaneously using a Group layer checkbox (ie, one high-level checkbox to control multiple lower-level layers).

This sample contains a nice Group layer control, but presumes that all the component layers may be switched on/off as VisibleLayers of a single Dynamic layer. This logic seems to be integral to the sample, so it doesn't look like a simple matter to modify it for feature and tiled layers. (Please let me know if I'm on the wrong track, and this sample would prove suitable)

The Legend Widget sample is more suitable as it simply switches any layer on/off (see the Natural Disasters panel on the right-hand side).

My question

How would I add a Group Layer control to the Legend Widget sample? eg, add a higher-level checkbox which will switch both Fire and Earthquakes layers on/off.

Best Answer

I haven't implemented it yet, but the sample at http://www.thejekels.com/dojo/Dijit_Tree_Chkbox.html looks suitable. This is what the TOC sample cited above uses. I'll try to customise it for my purposes

Related Question