[Users] How to remove node from GeoExt.tree.OverlayLayerContainer?

Robert Buckley robertdbuckley at yahoo.com
Wed Jan 19 09:36:07 CET 2011


Hi,

I have defined an GeoExt.tree.OverlayLayerContainer called "zusatzlayer". The 
store has to be set with no layers otherwise ALL layers are added

CODE:

// Zusatz Stores
    var zusatz_store = new GeoExt.data.LayerStore({
        id:"Zusatzlayer",
        text: "Zusatzlayer",
        map:map,
        initDir: 0,
        layers:[]
    });

layerRoot.appendChild(new GeoExt.tree.OverlayLayerContainer({
        id: 'Zusatzlayer',
        text: "<span class='TreeHeader'>Zusatzlayer</span>",
        layerStore: zusatz_store,
        leaf: false
        })
    );


In this OverlayLayerContainer I can append layers out of a grid using the 
following function in a bbar...

bbar: [new Ext.Button({
                 text: "Layer hinzuf&uuml;gen",
                 tooltip : 'Layer hinzuf&uuml;gen',
                 handler: function() {
                    capabilitiesgrid.getSelectionModel().each(function(record) {
                     var clone = record.clone();
                     clone.get("layer").mergeNewParams({
                        format: "image/png",
                         transparent: true
                     })        
                     
        layerRoot.getOwnerTree().getNodeById('Zusatzlayer').appendChild(new 
Ext.tree.TreeNode({
        text: clone.get("layer").name,
        checked: true,
        listeners: {
            'checkchange': function(node, checked){
                if(checked){
             //       Ext.MessageBox.alert(null, 'checked');
                    clone.get("layer").setVisibility(true);
                }else{
              //      Ext.MessageBox.alert(null, 'not checked');
                    clone.get("layer").setVisibility(false);
                }
            }
        },
        })    
    );

     // THIS ADDS THE LAYER

        mapPanel.layers.add(clone);    
            
        // zoom on to  new layer
        var bounds = new OpenLayers.Bounds.fromArray(clone.get("llbbox"))
        bounds.transform(epsg4326, map.getProjectionObject());
        map.zoomToExtent(bounds)
    
            });
        
        }
            
        
        })
        ,


THE PROBLEM...... If the treenode is expanded, the layer is being added twice!!!

Could anyone offer any solutions?

thanks for any help,

Rob

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.geoext.org/pipermail/users/attachments/20110119/87bae76a/attachment-0001.htm 


More information about the Users mailing list