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

Roger Kunkel rakunkel at ucdavis.edu
Wed May 30 17:35:07 EDT 2007


Thanks for your reply.
I was using the removeFeatures incorrectly.


On May 30, 2007, at 1:53 PM, Christopher Schmidt wrote:

> 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

Roger Kunkel
CERES Program
Dept. of Land Air & Water Resources
UC Davis
rakunkel at ucdavis.edu





More information about the Users mailing list