[Users] treePanel questions

Stefanie Weykam stefanie at weykam.net
Wed Nov 10 14:23:24 CET 2010


Hi list members,

I want to built a customized layer tree and group my layers thematically 
into nodes and subnodes, with individual titles and icons.
I have seen the postings from September and October but got a bit 
dazzled. There are a lot of interesting methods but for now I’d like to 
keep it simple.
Let me see if I got it right. Please correct me if I’m wrong:

1. I set up the map object and a mapPanel without adding any layers at 
this stage.

2. I set up a treePanel with root: { nodeType: "async" }, without any 
children yet.

3. I create several layerStores, one for each group of layers.
var layerStore_1 = new GeoExt.data.LayerStore({
map: map,
initDir: GeoExt.data.LayerStore.STORE_TO_MAP, //0
layers: [layer_1,layer_2] });
I’m not sure about the direction of the initial sync.

4. I create several layer containers, one for each group of layers
var layerContainer_1 = new GeoExt.tree.OverlayLayerContainer({
text: "my group title",
layerStore: layerStore_1,
loader: {param: "LAYERS"}
})
same for layerContainer_2 and layerStore_2

5. I set up the tree root node to which I will add the group nodes..
var treeRootNode = new Ext.tree.TreeNode({
text: "my title",
expanded: true
});

6. ..and I append each layerContainer to the tree root node
treeRootNode.appendChild(layerContainer_1);
treeRootNode.appendChild(layerContainer_2); etc


7. I set the treePanel’s tree root node. Only child is the treeRootNode 
which has already two children.
treePanel.setRootNode({
children: treeRootNode
});

8. And last not least I create a viewport with mapPanel and treePanel.

I also have a base layer group that I would add as baseLayerContainer, 
and a graticule ‘layer’ which I add at the end using action. The 
graticule should be on top and does not belong to any group.

var action = new GeoExt.Action({
control: grtCtrl,
map: map
});

So far my tree is empty, no error message. I suppose I missed a loader 
(?) or perhaps there is something wrong with my map-and-store 
synchronisation??

I am not sure if I really need the layerStores. I could as well access 
all the relevant parameters in my layer metadata (visibility, group, 
hideInLegend, etc).

Any comments are appreciated,



More information about the Users mailing list