AnsweredAssumed Answered

Legend - toggle services in AMD

Question asked by timw1984dev on Feb 7, 2014
Latest reply on Feb 7, 2014 by timw1984dev
Hey everybody!

Does anybody use the Legend - toggle services example in AMD format?

I tried to include it in my app, but I'm pretty new to JavaScript and this one is a head scratcher :)

Here is what I've got so far for that part of my code:

      var legendLayers = [];       var county = new FeatureLayer("",{         mode: FeatureLayer.MODE_ONDEMAND,         outFields:["*"]       });              //Create Legend       map.on("layers-add-result", function (evt) {         var layerInfo =, function (layer, index) {           return {layer:layer.layer,};         });         if (layerInfo.length > 0) {           var legendDijit = new Legend({             map: map,             layerInfos: layerInfo           }, "legendDiv");           legendDijit.startup();         }       });       map.addLayers([county]);       legendLayers.push({layer:county, title:"County"});      //Create Checkboxes       map.on("layers-add-result", function (evt) {, function (evt) {           var layerName = layer.title;           var checkBox = new CheckBox ({             name:"checkBox" +,             checked: layer.layer.visible,             onChange: function (evt) {               var clayer=map.getLayer(this.value);               clayer.setVisibility(!clayer.visible);               this.checked = clayer.visible;             }           });           //Move the checkboxes to TOC , dom.byId("toggle"), "after");           var checkLable = domConstruct.create('label', {'for', innerHTML:layerName}, checkBox.domNode, "after"); "<br />", checkLabel, "after");         });                });

If you used that example in AMD it would be nice to see working code.