Select to view content in your preferred language

AGSJS

5562
8
Jump to solution
10-07-2013 05:45 AM
MatejSkerjanc
Regular Contributor
Hello
we're using http://gmaps-utility-gis.googlecode.com/svn-history/r354/trunk/agsjs/docs/toc/examples.html
AGSJS Table of content
It seems it's using the dojo tree.
Dojo tree has collapse methods, while icannot find collapse method for this tree.

I need to collapse certain nodes, but i find no function available to achieve this. If anyone's more experienced in this it would help me tons.

Regards
Matej
0 Kudos
1 Solution

Accepted Solutions
KenBuja
MVP Esteemed Contributor
It turns out that this capability exists in the current TOC version. You can use

toc.findTOCNode(layerDynamic, 1).hide(); to remove layer 1

and

toc.findTOCNode(layerDynamic, 1).show(); to make it visible again.

See this sample. It will affect the Fire Stations legend entry.

If you want to do this when the TOC is being created, you'll have to put it into the Load event

            map.on("layers-add-result", function (evt) {                 toc = new TOC({                     map: map,                     layerInfos: [{                         layer: layerDynamic,                         title: "Legend",                         slider: true                     }]                 }, 'legendDiv');                 toc.startup();                                toc.on("load", function () {                     toc.findTOCNode(layerDynamic, 1).hide();                 });                            });

View solution in original post

0 Kudos
8 Replies
KenBuja
MVP Esteemed Contributor
There is a new version of the TOC tool that has the ability to collapse nodes. This is the latest version.
0 Kudos
MatejSkerjanc
Regular Contributor
Thanks! This will do.
0 Kudos
MatejSkerjanc
Regular Contributor
Another question regarding AGSJS, is it possible to omit certain feature layer by ID? I just want it out of the TOC but otherwise visible on the map.


Regards,
Matej
0 Kudos
MatejSkerjanc
Regular Contributor
it seems
var lyr = toc.findTOCNode(map.getLayer("operational0"), id);
                if (id == 5)
                    lyr.destroy();

works but its "buggy". It causes TOC to cease working correctly. Actually it works per se but reports bunch of errors on layer toggling.
0 Kudos
JeffPace
MVP Alum
instead of destroying,. maybe try

domStyle.set(lyr, 'visibility', 'hidden');

or

domStyle.set(lyr, 'display', 'none');
0 Kudos
KenBuja
MVP Esteemed Contributor
Unfortunately, neither of those work. I can see the visible attribute within lyr.data, but how do I set that to false?

[ATTACH=CONFIG]29504[/ATTACH]
0 Kudos
KenBuja
MVP Esteemed Contributor
It turns out that this capability exists in the current TOC version. You can use

toc.findTOCNode(layerDynamic, 1).hide(); to remove layer 1

and

toc.findTOCNode(layerDynamic, 1).show(); to make it visible again.

See this sample. It will affect the Fire Stations legend entry.

If you want to do this when the TOC is being created, you'll have to put it into the Load event

            map.on("layers-add-result", function (evt) {                 toc = new TOC({                     map: map,                     layerInfos: [{                         layer: layerDynamic,                         title: "Legend",                         slider: true                     }]                 }, 'legendDiv');                 toc.startup();                                toc.on("load", function () {                     toc.findTOCNode(layerDynamic, 1).hide();                 });                            });
0 Kudos
MatejSkerjanc
Regular Contributor
oh haha seriously? hide?

Thanks sirs, i used display none on the dom already but seemed so ... you know not clean.
I definitely prefer the hide method when provided.


Is it just me or am i blind, but....documentation seems a bit shoddy. But very nice tool.


Thank you both for the help!
0 Kudos