<html><head><style type="text/css"><!-- DIV {margin:0px;} --></style></head><body><div style="font-family:arial,helvetica,sans-serif;font-size:8pt">Hi,<br><br>I have defined an GeoExt.tree.OverlayLayerContainer called "zusatzlayer". The store has to be set with no layers otherwise ALL layers are added<br><br>CODE:<br><br>// Zusatz Stores<br> var zusatz_store = new GeoExt.data.LayerStore({<br> id:"Zusatzlayer",<br> text: "Zusatzlayer",<br> map:map,<br> initDir: 0,<br> layers:[]<br> });<br><br>layerRoot.appendChild(new GeoExt.tree.OverlayLayerContainer({<br> id: 'Zusatzlayer',<br> text: "<span class='TreeHeader'>Zusatzlayer</span>",<br>
layerStore: zusatz_store,<br> leaf: false<br> })<br> );<br><br><br><span style="color: rgb(255, 0, 0);">In this OverlayLayerContainer I can append layers out of a grid using the following function in a bbar...</span><br><br>bbar: [new Ext.Button({<br> text: "Layer hinzuf&uuml;gen",<br> tooltip : 'Layer hinzuf&uuml;gen',<br> handler: function() {<br> capabilitiesgrid.getSelectionModel().each(function(record)
{<br> var clone = record.clone();<br> clone.get("layer").mergeNewParams({<br> format: "image/png",<br> transparent: true<br> }) <br> <br> layerRoot.getOwnerTree().getNodeById('Zusatzlayer').appendChild(new
Ext.tree.TreeNode({<br> text: clone.get("layer").name,<br> checked: true,<br> listeners: {<br> 'checkchange': function(node, checked){<br> if(checked){<br> // Ext.MessageBox.alert(null, 'checked');<br> clone.get("layer").setVisibility(true);<br> }else{<br> // Ext.MessageBox.alert(null, 'not
checked');<br> clone.get("layer").setVisibility(false);<br> }<br> }<br> },<br> }) <br> );<br><br> // <span style="color: rgb(255, 0, 0);">THIS ADDS THE LAYER</span><br><br> mapPanel.layers.add(clone); <br> <br> // zoom on to new layer<br> var bounds = new OpenLayers.Bounds.fromArray(clone.get("llbbox"))<br> bounds.transform(epsg4326,
map.getProjectionObject());<br> map.zoomToExtent(bounds)<br> <br> });<br> <br> }<br> <br> <br> })<br> ,<br><br><br>THE PROBLEM...... If the treenode is expanded, the layer is being added twice!!!<br><br>Could anyone offer any solutions?<br><br>thanks for any help,<br><br>Rob<br><div><br></div>
</div><br></body></html>