AnsweredAssumed Answered

Re: Legend - toggle services - unchecked boxes

Question asked by eogriffin79 on Sep 9, 2013
Latest reply on Sep 10, 2013 by eogriffin79

I'm modifying this code a bit to make a web application:

The code produces a TOC and a legend, created dynamically using dynamic layers.

Is there any way of having the boxes unchecked when it opens? At the moment they are all checked.

This is the part of the code which controls the checkboxes. I thought it might be as easy as  exchanging
checked :layer.layer.visible, WITH
checked: false,

which does have some impact on the page but does not quite get there.

    //add check boxes
        dojo.forEach(legendLayers, function (layer) {
          var layerName = layer.title;
          var checkBox = new dijit.form.CheckBox({
            name    :"CheckBox" +,
            checked :layer.layer.visible,
            onChange:function (evt) {
              var clayer = map.getLayer(this.value);
              this.checked = clayer.visible;

Any ideas would be gratefully received!