[Users] How to find layer record from layer node ?
Tim Schaub
tschaub at opengeo.org
Tue Mar 23 23:37:09 CET 2010
Alexandre Dube wrote:
> Hi,
>
> I want to remove a layer from a LayerContainer, MapPanel and Tree.
> So far, destroying the layer (OL) and node.destroy() works, but the
> layer is still in the MapPanel layers. From the layertree node, is
> there a simple way to remove the according MapPanel layer record ? Or
> is there a method doing all that at once ?
>
If you have a MapPanel that is bound to a map, when you call
map.removeLayer or layer.destroy, the corresponding layer record will be
removed from the MapPanel's layer store.
In addition, if you have a MapPanel that is bound to a map and you call
MapPanel.layers.remove, the layer corresponding record will be removed
from the bound map.
In both of these cases, if you have used a LayerContainer that is
configured with the MapPanel's layer store (as the LayerContainer's
layerStore config property), the corresponding node will be removed from
a tree when the layer is removed.
The same happens for adding layers. This is how the LayerContainer
example works:
http://dev.geoext.org/trunk/geoext/examples/layercontainer.html
In these cases, I think it is easiest to think of the layer store
referenced by the MapPanel as the primary store. The the map is a view
of the records in this store. The tree (in this case) can also be
treated as a view. A grid could be another view. To keep things
simple, don't call methods on the views.
Tim
> Thanks,
>
--
Tim Schaub
OpenGeo - http://opengeo.org
Expert service straight from the developers.
More information about the Users
mailing list