<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 a treepanel which has child elements which work as data folders for wms layers....<br>I have added a grid which lists the other layers on my server (from the getcapabilities doc) and adds them to the map . <br><br>I have successfully achieved this, but am having the problem that the newly added layers from the window are being assigned to <span style="font-weight: bold;">each and every</span> root.child. <br><br>To solve this, I would like to add the layers from the gecapabilities doc grid to a new root.child called "MyLayers".<br><br>My logic is this.....II need to then write code to firstly check if the root.child with an id" MyLayers" exists, and if not... create it, and then add any layers to this child.<br><br>Is this possible? and how?<br><br><br>My Code...<br><br><div><span
style="color: rgb(255, 0, 0);">// Layer root container</span><br><br> var layerRoot = new Ext.tree.TreeNode({<br> text: "Karteninhalt",<br> expanded:false<br><br> });<br><br><span style="color: rgb(255, 0, 127);">// These are the content layer stores</span><br><br>// Baselayers<br> var layerListBase = new GeoExt.tree.BaseLayerContainer({<br> text: "<span class='TreeHeader'>Hintergrundkarten</span>",<br> map: map,<br> expanded: false<br><br> });<br><br>// Layer Stores - Nachrichtlich<br> var nachrichtlich_store = new GeoExt.data.LayerStore({<br> text:
"Grenzen",<br> map:map,<br> initDir: 0,<br> layers:[Grenzen]<br> });<br><br> // Layer Stores - WIND<br> var wea_store = new GeoExt.data.LayerStore({<br> text: "Windenergie",<br> map:map,<br> initDir: 0,<br> layers:[layer_windpotential,layer_wea_f,layer_wea]<br> });<br><br><span style="color: rgb(255, 0, 0);">// the tree is made here</span><br><br>layerRoot.appendChild(layerListBase);<br><br> layerRoot.appendChild(new GeoExt.tree.OverlayLayerContainer({<br> text: "<span class='TreeHeader'>Nachrichtlich</span>",<br> layerStore:
nachrichtlich_store,<br> expanded: false<br> })<br> );<br><br> layerRoot.appendChild(new GeoExt.tree.OverlayLayerContainer({<br> text: "<span class='TreeHeader'>Windenergie</span>",<br> layerStore: wea_store,<br> expanded: false<br> })<br> );<br><br><br>...the extract from the button in the grid which adds the layers from the getcapabilities doc...<br><br>bbar: [new Ext.Button({<br> text: "Layer hinzuf&uuml;gen",<br> tooltip : 'Layer hinzuf&uuml;gen',<br>
handler: function() {<br><br> // select layer from grid<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> // add layer to map<br> mapPanel.layers.add(clone);<br> <br> if(node) {<br> var node = tree.getNodeById('MyLayers'); <br> tree.node.add(node,clone);<br><br> }<br> <br> // zoom to nely added 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>Thanks for any help,<br><br><br>Robert<br><br><br><br><br><br><br><br><br></div>
</div><br></body></html>