[Users] MVC with LayerTree

Antonio Parrotta antonioparrotta at gmail.com
Fri Jan 25 16:35:01 CET 2013


Hi,

I'm trying to make an  MVC app with a panel that contains a LayerTree using
EXTJS4 and GeoExt2.

Basically the problem is that the layertree needs to have the layer store
available on init but data are actually not ready, so layer tree can be
there before the map (or layer store) is available. The result of this is
that layers are not displayed in the tree. I tried to reload the stores
without any success. Do you have any hint?

Thanks a lot

I have then a

Ext.define('Pandora.view.LayersTree', {
    // Ext.panel.Panel-specific options:
    extend: 'GeoExt.tree.Panel',
   store: 'LayersTree',
.....


then
Ext.define('Pandora.store.LayersTree',  {
    extend: 'Ext.data.TreeStore',
model: 'GeoExt.data.LayerTreeModel',

root: {
expanded: true,
children: [ {
plugins: [{
ptype: 'gx_layercontainer',
 loader: {
store: Ext.data.StoreManager.lookup('LayersMap'),//map.layers,
createNode: function(attr) {
// add a WMS legend to each node created
if(!(attr.layer instanceof OpenLayers.Layer.OSM || attr.layer instanceof
OpenLayers.Layer.Vector))
{
attr.component = {
xtype: "gx_wmslegend",
layerRecord: mapPanel.layers.getByLayer(attr.layer),
showTitle: false,
// custom class for css positioning
// see tree-legend.html
cls: "legend"
};
};
return GeoExt.tree.LayerLoader.prototype.createNode.call(this, attr);
}

and the layerstore

Ext.define('Pandora.store.LayersMap', {
    extend: 'GeoExt.data.LayerStore',
autoload : false

and finally

in the map I simply do

store: 'LayersMap',
...
Ext.data.StoreManager.lookup(this.store).bind(map);




- Antonio
il
*articolo*: *il, la, le, i, lo, l ', gli, lo stesso*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.geoext.org/pipermail/users/attachments/20130125/24c90715/attachment.htm 


More information about the Users mailing list