[OpenLayers-Users] Deleting a Vector Layer - How?

Eric Lemoine eric.c2c at gmail.com
Tue Aug 12 16:25:13 EDT 2008


Hi. You should do removeLayer(layer) to remove it from the layer and
layer.destroy() to destroy it and therefore avoid memory leaks. The
way you do it does seem ok to except you do destroyFeatures twice
since it's done in destroy. If "removeLayer then layer.destroy()"
fails it most probably means there's a bug in OpenLayers. Eric

2008/8/12, Bill Thoen <bthoen at gisnet.com>:
> I need to get rid of a vector layer and all of its contents, but I'm not
> sure of the syntax. When I try:
>
>   if (myLayer != null) {
>     map.removeLayer( myLayer );
>     myLayer.vector.destroyFeatures();
>     myLayer.vector.destroy();
> }
>
> it seems to die on  'myLayer.vector.destroyFeatures();' How should I do
> this?
>
> - Bill Thoen
>
>
>
>
> _______________________________________________
> Users mailing list
> Users at openlayers.org
> http://openlayers.org/mailman/listinfo/users
>



More information about the Users mailing list