AnsweredAssumed Answered

Layer Visualization

Question asked by bobm1026 on Dec 18, 2014
Latest reply on Jan 8, 2015 by bobm1026

I am in the process of developing a replacement web map for a response map (  After giving up on ArcGIS Online's ability to crate a useful map, I am now giving ArcGIS for JavaScript a try.  I am running into a fairly common problem in that I would like to be able to load a group of  layers that can be switched on and off by the users as needed.  I have seen many suggestions, none of which work.  This code is how I call the layer.  It works.

//========================================  Agency for Persons with Disabilities Contractors

        var APD = new esri.layers.FeatureLayer("")




This is the checkbox I use to turn on/off the layer.  It works:


                        <label><input type='checkbox'  name="APD";  

                         onclick='ChangeLayerVisiblity(name,this.checked);'>APD Contractors</label><br/>


This is my latest failed code:


//========================================  Layer Visibility

        function ChangeLayerVisiblity(LayerName, IsChecked){ 

              if (LayerName === "APD"){

                   if(IsChecked == true){

                       window.alert(LayerName + " is " + "ON" );




                       window.alert(LayerName + " is " + "OFF" );




NOTE:  if I comment out the two setVisibility lines the code works, but of course it doesn't turn off/on the layer.  The setVisibility line in the constructor does work, but not in the function.


Surely, if the layer is constructed with a visibility attribute, it can be manipulated from code otherwise, why have it?


What am I missing here?