I'm working with Arc's API for a school project. I have put in a few widgets into my script. The only one I am having issues with is the legend/Toggle, I am unable to get the toggle to work. Can someone take a look at my script and let me know what I'm doing wrong. I've been at this for about a week and I just don't know what I'm doing wrong. I followed all the directions. Thank you,
var map, legendLayers = [];
function init() { map = new esri.Map("map", { basemap: "topo", center: [-110.934448, 32.331238], zoom: 10 });
//add check boxes dojo.forEach(legendLayers,function(layer){ var layerName = layer.title; var checkBox = new dijit.form.CheckBox({ name: "checkBox" + layer.layer.id, value: layer.layer.id, checked: layer.layer.visible, onChange: function(evt) { var clayer = map.getLayer(this.value); clayer.setVisibility(!clayer.visible); this.checked = clayer.visible; } });
//add the check box and label to the toc dojo.place(checkBox.domNode,dojo.byId("toggle"),"after"); var checkLabel = dojo.create('label',{'for':checkBox.name, innerHTML:layerName},checkBox.domNode,"after"); dojo.place("<br />",checkLabel,"after"); }); });