[Users] Question about turning on entire group of layers in layercontainer/treenode

Andrew Stewart Andrew.Stewart at reddeer.ca
Fri Sep 17 17:37:23 CEST 2010


Sorry didn't realize it was pasted all messed up, here is the code a little more readable thanks



        //Labels LayerList
        var layerList_Labels = new GeoExt.tree.LayerContainer({
        text: 'Labels',
        layerStore: mapPanel.layers,
        leaf: false,
        cls: 'rootnode',
        enableDD: true,
        expanded: false,
        loader:
        {
            filter: function(record)
            {
                var myarr = new Array();
                myarr[0] = record.get("layer").name.indexOf("Overview Streets");
                myarr[1] = record.get("layer").name.indexOf("Quadrant Streets");
                myarr[2] = record.get("layer").name.indexOf("Neighbourhood Streets");
                myarr[3] = record.get("layer").name.indexOf("Block Streets");
                myarr[4] = record.get("layer").name.indexOf("Proposed Streets");
                myarr[5] = record.get("layer").name.indexOf("Address Label (Overview)");
                myarr[6] = record.get("layer").name.indexOf("Address Label (Detail)");
                if(myarr[0]==-1 && myarr[1]==-1 && myarr[2]==-1 && myarr[3]==-1 && myarr[4]==-1 && myarr[5]==-1 && myarr[6]==-1)
                {
                return false;
                }
                else
                {
                return true;
                }
            }
            }
        });


        //declare root tree node
        var layerRoot = new Ext.tree.TreeNode({
            enableDD: true,
            text: "All Legend Items",
            expanded: true
            });

       //add children to root node
       layerRoot.appendChild(layerList_Labels)
       layerRoot.appendChild(layerlist_AOI)
       layerRoot.appendChild(layerlist_Trails)
       layerRoot.appendChild(layerlist_Footprints)
       layerRoot.appendChild(layerlist_LegalFabric)
       layerRoot.appendChild(layerlist_ParcelFabric)
       layerRoot.appendChild(layerlist_Base)
       layerRoot.appendChild(layerlist_Orthos)


        var layerTree = new Ext.tree.TreePanel({
        title: '',
        renderTo: 'legend',
        root: layerRoot,
        enableDD: true,
        applyLoader: true,
        rootVisible: false



________________________________
From: Pol [mailto:d.paolino at gmail.com]
Sent: September 17, 2010 9:33 AM
To: Andrew Stewart
Subject: Re: [Users] Question about turning on entire group of layers in layercontainer/treenode

Dude,

Is it possible for you to indent your code ? It's really easier to read and to understand it...

Thanks !

-Pol D.-
http://www.google.com/profiles/110003197662276240659


On Fri, Sep 17, 2010 at 17:23, Andrew Stewart <Andrew.Stewart at reddeer.ca<mailto:Andrew.Stewart at reddeer.ca>> wrote:

 I have a layerlist that is working fine and being entered into a layercontainer/treepanel to show all my layers. Everything works fine but I am wondering if there is a way to turn on all layers by adding a checkbox to the group much like checkboxes are next to all individual layers I have. Appreciate any advice on how to modify my existing code to accomplish this so I can turn all my layers on by clicking the group (root layer) or if there is another way to do this, thanks.

 //Labels LayerList

var layerList_Labels = new GeoExt.tree.LayerContainer({

text:

'Labels',

layerStore: mapPanel.layers,

leaf:

false,

cls:

'rootnode',

enableDD:

true,

expanded:

false,

loader:

{

filter:

function(record)

{

var myarr = new Array();

myarr[0] = record.

get("layer").name.indexOf("Overview Streets");

myarr[1] = record.

get("layer").name.indexOf("Quadrant Streets");

myarr[2] = record.

get("layer").name.indexOf("Neighbourhood Streets");

myarr[3] = record.

get("layer").name.indexOf("Block Streets");

myarr[4] = record.

get("layer").name.indexOf("Proposed Streets");

myarr[5] = record.

get("layer").name.indexOf("Address Label (Overview)");

myarr[6] = record.

get("layer").name.indexOf("Address Label (Detail)");

if(myarr[0]==-1 && myarr[1]==-1 && myarr[2]==-1 && myarr[3]==-1 && myarr[4]==-1 && myarr[5]==-1 && myarr[6]==-1)

{

return false;

}

else

{

return true;

}

}

}

});

//declare root tree node

var layerRoot = new Ext.tree.TreeNode({

enableDD:

true,

text:

"All Legend Items",

expanded:

true

});

//add children to root node

layerRoot.appendChild(layerList_Labels)

var layerTree = new Ext.tree.TreePanel({

title:

'',

renderTo:

'legend',

root: layerRoot,

enableDD:

true,

applyLoader:

true,

rootVisible:

false

});

________________________________
This e-mail is intended for the original recipient(s) only. If you have received it in error, please advise the sender and delete this message.

_______________________________________________
Users mailing list
Users at geoext.org<mailto:Users at geoext.org>
http://www.geoext.org/cgi-bin/mailman/listinfo/users



________________________________
[This message has been scanned for security content threats and viruses.]

[The City of Red Deer I.T. Services asks that you please consider the environment before printing this e-mail.]



-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.geoext.org/pipermail/users/attachments/20100917/0b1c242b/attachment-0001.htm 


More information about the Users mailing list