on(map, "layers-add-result", function(e) { var toc = new agsjs.dijit.TOC({ map: map, layerInfos:legendLayers }, 'legendDiv'); toc.startup(); });
dojo.connect(map,'onLayersAddResult', function(results){ var toc = new agsjs.dijit.TOC({ map: map, layerInfos:legendLayers }, 'legendDiv'); toc.startup(); });
Solved! Go to Solution.
Hmmm... could you replicate the issue with http://jsfiddle.net/ so I can take a look at your code?
Hmm. I can't replicate it http://jsfiddle.net/NcCWw/7/. It's working in this instance. Just not working with my full code. I suppose it's possible that it's the TOC widget I'm using that's causing the issue.
OK great! We've narrowed it down.
I would try initializing the TOC before my ready and parser calls, to make sure it's accessible when the page first loads.
this.map = new Map("map", { infoWindow: popup, basemap: "streets", autoResize: true, sliderStyle: style, logo: false, showAttribution: false, lods: lods }); map = this.map; var tocAdder = map.on('layers-add-result', lang.hitch(this, function(results) { // alert('in onlayeradd'); if (!this.toc) { this.toc = new agsjs.dijit.TOC({ map: map, layerInfos: layerInfos.reverse() }, 'tocDiv'); toc = this.toc; toc.startup(); lang.hitch(this, createLegend());
map.addLayers([eezLayer, eezFeatureLayer]); dojo.connect(map, 'onLayersAddResult', function(results) { var toc = new agsjs.dijit.TOC({ map: map, layerInfos: [{ layer: eezLayer, title: "Enhanced Enterprise Zones", slider:true },{ layer: districtLayer, title: "Legislative Districts" }] }, 'tocDiv'); toc.startup(); });
since the map class itself is evented, i'm not sure I understand the need to try and use 'dojo/on' to handle event wiring.
@tracy. also not sure whats causing your problem.