hmm this might be a brute-force way of doing this, but I think writing an event handler for everytime a new layer is added (assuming by button click) you traverse the entire tree..<br><br>for(var c = 0; c < layerRoot.getOwnerTree().getNodeById(<a href="http://parent.id">parent.id</a>).childNodes.length; c++){<br>
layerRoot.getOwnerTree().getNodeById(<a href="http://parent.id">parent.id</a>).childNodes[c].eachChild(function(node) { <br> if (<a href="http://node.layer.name">node.layer.name</a> == map.getLayersByName(layerName)) { <br>
//then put logic in here...maybe create a count variable or something like<br> layerExists += 1;<br> }//end if <br> });//end eachChild<br> }//end for<br><br>Hope this gives you some kind of lead,<br>
<br>elshae<br><br><div class="gmail_quote">On Tue, Jan 18, 2011 at 12:09 PM, 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 am trying to write a function which checks to see if a layer is present in the tree.<br><br>if the layer already exists in the tree (or map) is shouldn´t be loaded...<br>
<br><br>can anyone help?<br><br><div>var clonename = clone.get("layer").name<br> <br> if (mapPanel.layers(clonename)) {<br> Ext.MessageBox.alert(null, "test");<br> }<br>
else <br> {<br>
mapPanel.layers.add(clone);<br> Ext.MessageBox.alert(null, clonename);<br> }<br><br>Cheers<br>Rob<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>