[Users] how to find a layer in layertree
IT Intern
itintern12 at gmail.com
Tue Jan 18 18:32:39 CET 2011
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..
for(var c = 0; c <
layerRoot.getOwnerTree().getNodeById(parent.id).childNodes.length;
c++){
layerRoot.getOwnerTree().getNodeById(parent.id).childNodes[c].eachChild(function(node)
{
if (node.layer.name == map.getLayersByName(layerName)) {
//then put logic in here...maybe create a count variable or
something like
layerExists += 1;
}//end if
});//end eachChild
}//end for
Hope this gives you some kind of lead,
elshae
On Tue, Jan 18, 2011 at 12:09 PM, Robert Buckley
<robertdbuckley at yahoo.com>wrote:
> Hi,
>
> I am trying to write a function which checks to see if a layer is present
> in the tree.
>
> if the layer already exists in the tree (or map) is shouldn´t be loaded...
>
>
> can anyone help?
>
> var clonename = clone.get("layer").name
>
> if (mapPanel.layers(clonename)) {
> Ext.MessageBox.alert(null, "test");
> }
> else
> {
> mapPanel.layers.add(clone);
> Ext.MessageBox.alert(null, clonename);
> }
>
> Cheers
> 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/20110118/7c44a612/attachment-0001.htm
More information about the Users
mailing list