Select to view content in your preferred language

JavaScript - TOC layers callapse & expand

1935
4
Jump to solution
12-12-2014 08:02 AM
ShaningYu
Honored Contributor

From the example: http://gmaps-utility-gis.googlecode.com/svn/tags/agsjs/latest/examples/toc.html ,

I added

    autoToggle: false  //whether to automatically collapse when turned off, and expand when turn on for groups layers. default true.

in the TOC layer's code.  However, in my application, this function does work. 

Besides, how to set the layer as checked-off initially in the TOC?

Thanks if you can help.

Tags (1)
0 Kudos
1 Solution

Accepted Solutions
KenBuja
MVP Esteemed Contributor

To have a layer show up as collapsed in the TOC, set its visibility to false once its loaded. Here's an example

layerDynamic = new ArcGISDynamicMapServiceLayer(yourURL, {
    id: 'Dynamic'
});

layerDynamic.on("load", function () { layerDynamic.setVisibility(false); })

View solution in original post

4 Replies
KenBuja
MVP Esteemed Contributor

To have a layer show up as collapsed in the TOC, set its visibility to false once its loaded. Here's an example

layerDynamic = new ArcGISDynamicMapServiceLayer(yourURL, {
    id: 'Dynamic'
});

layerDynamic.on("load", function () { layerDynamic.setVisibility(false); })
ShaningYu
Honored Contributor

Thanks a lot.

0 Kudos
KenBuja
MVP Esteemed Contributor

Of course, it's easier to just the layer's visibility to false when you create it. I should have suggested that first...

layerDynamic = new ArcGISDynamicMapServiceLayer(yourURL, {
    id: 'Dynamic',
    visible: false
});
0 Kudos
ShaningYu
Honored Contributor

Thanks a lot.

0 Kudos