AnsweredAssumed Answered

Can I modify TOC.js to honor the setVisibleLayers I've defined?

Question asked by schlot on Dec 6, 2013
Latest reply on Aug 11, 2017 by Mr_Kirkwood
If I limit the layers that are visible in my ArcGISDynamicMapService layer using setVisibleLayers, how can I modify the TOC.js dijit to honor these?  I have multiple layers in this service and I only need one of them for this particular project.  If I limit what is loaded, I get empty checkboxes for the other layers that aren't visible, but without any labels next to them.  No group layers or anything involved, just a service with more than one layer in it. 

I thought I read another thread about this, but I couldn't search it out.  [ATTACH=CONFIG]29657[/ATTACH]
   var countyLayer = new ArcGISDynamicMapServiceLayer(pathName+"/ArcGIS/rest/services/BaseMap/BasicBoundary/MapServer", {id:'countyLayer', visible:false})
  countyLayer.setVisibleLayers([3]);

//other layers I added, map gets created ....

   app.map.on("layers-add-result", function (event) {
        try {
            var toc = new agsjs.dijit.TOC({
              map: app.map,
            layerInfos: [{
             layer: controlLayer,
            title: "Control Points"
          },{
             layer: plssLayer,
            title: "Public Land Survey System"
          },{
             layer: twpRngLayer,
             title: "Township / Range"
          },{
              layer:countyLayer,
              title:"Missouri Counties"               
                }]
            }, 'tocDiv');
            toc.startup();
        }
        catch (e) {
            console.log(e.message);
        }

       });


I have poked around a bit in the TOC code, but I think this is the original behavior and not something I've introduced by accident.

Attachments

Outcomes