[Users] How to add multiple components to a tree store node

Juliette Fabre juliette.fabre at univ-montp2.fr
Tue Jan 6 10:20:01 CET 2015


Hello,

I'm trying to add a WMS legend AND an opacity slider to each node of a 
tree store.
I can add each component separately, but not together ...

It could be something like this, but attr.component = [{...}, {}] raises 
errors .. :

var tree_store = Ext.create('Ext.data.TreeStore', {
     model: 'GeoExt.data.LayerTreeModel',
     root: {
         expanded: true,
         children: [
         {
             // Base layers
             plugins: ['gx_baselayercontainer'],
             expanded: true,
             text: "Base maps"
         },
         {
             // Overlays
             plugins: [{
                 ptype: "gx_overlaylayercontainer",
                 loader: {
                     createNode: function(attr) {
                         attr.component =
                         [
                         // Add a WMS legend to each node created
                         {
                             xtype: "gx_wmslegend",
                             layerRecord: 
mapPanel.layers.getByLayer(attr.layer),
                             showTitle: false,
                             baseParams: {
                                 // Overrides gif format that is ugly in 
this case
                                 FORMAT: 'image/png',
                                 LEGEND_OPTIONS: 'forceLabels:off'
                             },
                         },
                         // Add an opacity slider
                         {
                             xtype: "gx_opacityslider",
                             layer: attr.layer,
                             vertical: false,
                             value: 100,
                             //x: 100,
                             //y: 100,
                             width: 200,
                             aggressive: true,
                             listeners: {
                                 change: function(slider, val) {
                                     attr.layer.setOpacity(val/100);
                                 }
                             }
                         }];
                         return 
GeoExt.tree.LayerLoader.prototype.createNode.call(this, attr);
                     }
                 }
             }],
             expanded: true,
             text: "Layers",
         }]
     }
});

Any idea?

Thanks,

Juliette

-- 
Juliette Fabre
Ingénieur d'Etudes Systèmes d'Information Scientifiques
OSU OREME
Bât. 22, bureau 220, Université Montpellier 2
Place Eugène Bataillon - CC 22002, 34095 Montpellier
Tél : 04 67 14 40 41
data.oreme.org



More information about the Users mailing list