Viewing By Entry / Main
July 17, 2008
Simple ArcGIS Server Layer list - Pure Javascript Example
Thanks to Jeremy Bartley from the the Arcgis Server Team (and MapDex.org fame)for sending this pure javascript version of the ArcGIS Server layer list sample I did in my previous post.
Check it out here:
http://maps.roktech.net/demo/layerlist_js.html
Comments
The layer list is very simple and straightforward. After copying the code into my ArcGIS Server 9.3 Javascript API website, I noticed that all the layers were checked even though all the layers were not turned on.
I updated the following line in the "buildLayerList" function to correct this problem:
Old:
items[i] = "<input type='checkbox' class='list_item' checked='" + (info.defaultVisibility ? "checked" : "") + "' id='" + info.id + "' onclick='updateLayerVisibility();' /><label for='" + info.id + "'>" + info.name + "</label>";
New:
items += "<input type='checkbox' class='list_item' " + (info.defaultVisibility ? " CHECKED " : "") + " id='" + info.id + "' onclick='updateLayerVisibility();' /><label for='" + info.id + "'>" + info.name + "</label><br>";
I am working on a TOC that will function more like the WebADF toc, and will post an example here when it is complete.
-Trent
I updated the following line in the "buildLayerList" function to correct this problem:
Old:
items[i] = "<input type='checkbox' class='list_item' checked='" + (info.defaultVisibility ? "checked" : "") + "' id='" + info.id + "' onclick='updateLayerVisibility();' /><label for='" + info.id + "'>" + info.name + "</label>";
New:
items += "<input type='checkbox' class='list_item' " + (info.defaultVisibility ? " CHECKED " : "") + " id='" + info.id + "' onclick='updateLayerVisibility();' /><label for='" + info.id + "'>" + info.name + "</label><br>";
I am working on a TOC that will function more like the WebADF toc, and will post an example here when it is complete.
-Trent