[Users] Different layer containers in a single layer tree

294 views
Skip to first unread message

Luís de Sousa

unread,
Mar 14, 2012, 11:12:08 AM3/14/12
to us...@geoext.org
Dear all,

I'm trying to code a layer tree with two containers: one for base
layers and another for overlays. Using the code that goes below I'm
getting two containers but both are listing all the layers. Besides
this, the containers are listed inside an additional node in the three
without a name. What am I doing wrong?

Thank you for the help,

Luís

######################################################################

var baseLayerList = new GeoExt.tree.LayerContainer({
text: 'Base Layers',
layerStore: mapPanel.layers,
leaf: false,
expanded: true,
nodeType:'gx_baselayercontainer',
});

var overlayList = new GeoExt.tree.LayerContainer({
text: 'Overlays',
layerStore: mapPanel.layers,
expanded: true,
nodeType:'gx_overlaylayercontainer',
});

var treeRoot = new Ext.tree.AsyncTreeNode({
expanded: true,
children: [
baseLayerList,
overlayList
]
});

var layerTree = new Ext.tree.TreePanel({
title: 'Map Layers',
root: treeRoot,
region: "east",
width: 170,
collapsible: true,
autoScroll: true,
enableDD: true,
});
_______________________________________________
Users mailing list
Us...@geoext.org
http://www.geoext.org/cgi-bin/mailman/listinfo/users

Christian Mayer

unread,
Mar 27, 2012, 1:52:49 AM3/27/12
to us...@geoext.org
Hi Luis,

I think you mixed up two things: instead of using a direct instanciation of the GeoExt.tree.LayerContainer AND giving an nodeType in both cases you should use a declaration with only a nodeType like this

var baseLayerList = {
    "nodeType": "gx_baselayercontainer"
       ...
};


The same with the overlay container.


The things with the "additional node in the tree without a name":  This is the so called root node. By giving your TreePanel instance the config option
rootVisible: false

the root folder could be hidden.

More infos could be found here:
http://geoext.org/lib/GeoExt/widgets/tree/BaseLayerContainer.html
http://geoext.org/lib/GeoExt/widgets/tree/OverlayLayerContainer.html
http://api.geoext.org/1.1/examples/tree.html



Best regards,
Chris

Luís de Sousa

unread,
Mar 29, 2012, 5:04:09 AM3/29/12
to us...@geoext.org
Dear Christian, thank you for your input.

Reading your message and going through the examples, it seems to me it
has to be something like the code that goes below. Unfortunately, this
is resulting in some sort of hang up, a waiting icon is show be each
node and no layers are shown (see image attached). Any further ideas?

Thank you,

Luís

######################################################################

var treeConfig = [{
nodeType: "gx_baselayercontainer",
expanded: true
}, {
nodeType: "gx_overlaylayercontainer",
expanded: true
}];



var layerTree = new Ext.tree.TreePanel({

region: "east",
title: 'Map Layers',


width: 170,
collapsible: true,
autoScroll: true,
enableDD: true,

plugins: [{
ptype: "gx_treenodecomponent"
}],
root: {
children: treeConfig
},
rootVisible: false
});

LayerContainers.png
Reply all
Reply to author
Forward
0 new messages