[Users] Tree advice

Matt Priour mpriour at kestrelcomputer.com
Wed Aug 10 20:57:56 CEST 2011


This is actually really easy Robert.
You need to implement the ‘filter’ function of the LayerLoader so that layers are grouped properly
Here is the simplest but also most manual way to go about it.
Assumptions: each layer has a ‘division’ attribute of the format “X.X” and the layer store is configured to read that attribute
{
//... Tree Panel config ...
root: {
    nodeType: 'async',
    children: [{
        nodeType: "gx_baselayercontainer",
        text: 'BaseLayersDir'
    }, {
        nodeType: "gx_overlaylayercontainer",
        expanded: true,
        title: 'Dir 1',
        loader: {
            filter: function(rec){
                var div = rec.get('division');
                return div.split('.')[0] == 1;
            }
        }
    }, {
        nodeType: "gx_overlaylayercontainer",
        expanded: true,
        title: 'Dir 2',
        loader: {
            filter: function(rec){
                var div = rec.get('division');
                return div.split('.')[0] == 2;
            }
        }
    }, {
        nodeType: "gx_overlaylayercontainer",
        expanded: true,
        title: 'Dir 3',
        loader: {
            filter: function(rec){
                var div = rec.get('division');
                return div.split('.')[0] == 3;
            }
        }
    }]
},
....More Tree Panel Config
}

There are other more automated ways to go about it. However, this should get you started.

One word of caution, if you try to do some more fancy stuff and want to use a loader with native ExtJS nodeType, then you must provide loader with an actual loader instance and NOT just the configuration for the loader. Only ‘gx_layercontainer’ and its subclass nodeTypes will automatically instantiate the loader for you from config. Other nodeTypes will ignore it if it is not already an instance.

Matt Priour
Kestrel Computer Consulting

From: Robert Buckley 
Sent: Wednesday, August 10, 2011 3:59 AM
To: users at geoext.org 
Subject: [Users] Tree advice

Hi,

I want to know how to create a geoext layer tree....but the "right" way!

I have seen examples such as here in the Haiiti Map ("http://hypercube.telascience.org/haiti/") where multiple stores are created to group the layers together and then add them as nodes to the tree root.

However, although this works, Mr Andreas Hocevar has written this regarding a similar topic regarding creating a hierarchical tree structure...."What you want is easy to do. Just get rid of the multiple layer stores. There are in fact many ways to do what you want. What I have done previously, for example, is to have layer nodes with a "group" field, and set the filter of the LayerLoader of each LayerContainer to only accept layer records that match a specific group name."

I take his word as gospel, and therefore would like to know (possibly with a few code examples if anyone has any) what is the best way to achieve a nested tree structure with Directories in Directories which contain layers such as in the following diagram


Root > BaselayersDir
>BaseLayer 1
>BaseLayer 2
        > Dir1
>Dir1:1
>Layer 1
>Layer 2
>Dir1:1
>Layer 1
>Layer 2
>Dir1:2
>Layer 1
>Layer 2
        > Dir2
>Dir2:1
>Layer 1
>Layer 2
>Dir2:1
>Layer 1
>Layer 2
>Dir2:2
>Layer 1
>Layer 2
        > Dir3
>Dir3:1
>Layer 1
>Layer 2
>Dir3:1
>Layer 1
>Layer 2
>Dir3:2
>Layer 1
>Layer 2


How many way can one achieve this then? and what is a good method and what is a bad one?




Thanks for any advice,

Rob 






--------------------------------------------------------------------------------
_______________________________________________
Users mailing list
Users at geoext.org
http://www.geoext.org/cgi-bin/mailman/listinfo/users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.geoext.org/pipermail/users/attachments/20110810/3b3f7028/attachment.htm 


More information about the Users mailing list