[OpenLayers-Users] how to cleanly remove a vector layer

Christopher Schmidt crschmidt at metacarta.com
Wed May 30 16:53:41 EDT 2007


On Wed, May 30, 2007 at 01:36:41PM -0700, Roger Kunkel wrote:
> 
> I'm having trouble using and then removing a vector layer.
> removeFeatures() - produces errors saying that the feature is not  
> defined when feature.geometry is referenced.

map.layers[1].removeFeatures(map.layers[1].features); works for me on
http://openlayers.org/dev/examples/vector-features.html .

> calling destroy on the layer causes continuous mouse event errors
> - it seems that the getFeatureFromEvent method keeps getting called  
> even though I've destroyed the layer.

Yep. That's a bug. The only piece of advice I have for that is to not
destroy a layer if you have selectefatures handler on it :) I'll file it
as a bug.

Regards,
-- 
Christopher Schmidt
MetaCarta



More information about the Users mailing list