I know you can use a loader with a filter to specify which layer you do not want to append to a container<br><br>new GeoExt.tree.OverlayLayerContainer({<br> text: text,<br> layerStore: layerStore,<br>
expanded: true,<br> iconCls: iconCls, //If not specified, defaults to original image<br> loader:{<br> filter: function(record) {<br> //return record.get("layer").name.indexOf("Tasmania") !== -1 This code means attach any layers with "Tasmania" in their name, notice the the (!== -1)<br>
return record.get("layer").name.indexOf("Photos") == -1 && record.get("layer").name.indexOf("OpenLayers.Handler.Polygon") == -1 && record.get("layer").name.indexOf("OpenLayers.Handler.Path") == -1; This code means do NOT take any layers with "Photos", "OpenLayers.Handler.Polygon", or "OpenLayers.Handler.Path" in their name notice the (== -1)<br>
}<br> }<br> })<br><br><br>Hope this help you somehow<br><br>Happy Mapping,<br><br>elshae<br><br><br><div class="gmail_quote">On Tue, Jan 18, 2011 at 4:09 AM, Robert Buckley <span dir="ltr"><<a href="mailto:robertdbuckley@yahoo.com">robertdbuckley@yahoo.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><div><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></div><br>_______________________________________________<br>
Users mailing list<br>
<a href="mailto:Users@geoext.org">Users@geoext.org</a><br>
<a href="http://www.geoext.org/cgi-bin/mailman/listinfo/users" target="_blank">http://www.geoext.org/cgi-bin/mailman/listinfo/users</a><br>
<br></blockquote></div><br>