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

Matt Priour mpriour at kestrelcomputer.com
Wed Jan 19 16:15:06 CET 2011


I understand you are honestly trying to figure out how to use GeoExt and teaching yourself how to program using the OpenGeo stack, however at this point I think you have become a "Help Vampire" [1] .

You are not following recommendations given on the list, not reading the documentation, not following the examples, and not opening the GeoExt library source to understand how things work.

The behavior you describe below is exactly what one would expect. You have been given the answer before and warned against trying to use multiple stores and encouraged to learn how to use the loader's filter function, yet I see the same errors below.

An 'async' tree node (which all LayerNodes and LayerContainerNodes are derived from) fire their load function when they are expanded. Look at the code for the OverlayLayerContainer's load function and you will see very easily why this problem is happening. You should also be able to quickly gain a much better understanding of the right way to configure your nodes so that they behave in the expected manner.

While I certainly understand the difficulty of learning something completely new and trying to do your normal job as well (trust me, I've been there, as have most others on this list), we can't hold your hand and give you answer after answer unless you are also making an equal effort to actually learn the tools. Spend a few evenings or weekends following through the source code, take the examples and start changing them in a controlled way so that you understand the effect of different options or techniques for doing things.

GeoExt is a fairly high level library. You can use it in a lot of scenarios with little understanding of the libraries it depends on and it will do all kinds of cool things automatically. However, due to its dependence on both OpenLayers & ExtJS, if you want to do something extra or custom with GeoExt, then you really need to understand it's inner workings or you will continue to have problems.


Matt Priour
Kestrel Computer Consutling

[1] http://slash7.com/2006/12/22/vampires/




From: Robert Buckley 
Sent: Wednesday, January 19, 2011 2:36 AM
To: users at geoext.org 
Subject: [Users] How to remove node from GeoExt.tree.OverlayLayerContainer?


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







--------------------------------------------------------------------------------


_______________________________________________
Users mailing list
Users at geoext.org
http://www.geoext.org/cgi-bin/mailman/listinfo/users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.geoext.org/pipermail/users/attachments/20110119/05b8aace/attachment.htm 


More information about the Users mailing list