Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a problem ( How to stop features to redraw unwillingly in OpenLayers ) that might be solved by aborting the beforefeatureremoved or beforefeaturesremoved event.

What I would like to to is to stop the layer from refreshing (removing and the adding again) features from a vector layer. If I for example make a javscript error in those methods the features isn't removed or refreshed. But causing a javascripts error causes other issues so I hope that there is a controlled way of doing this in Openlayers

I have tried the{

But it doesnt seem to do anything, Im I

Br Mike

share|improve this question
Have you tried to return false? – Tommaso Feb 6 '13 at 16:11
Yes, and sadly that don't help either. – Mike001 Feb 6 '13 at 16:24

Unfortunately the beforefeatureremoved and beforefeaturesremoved events will not prevent features from being removed when returning false from a listener - although the name would suggest such behavior.

share|improve this answer
Hi ahocevar Since you help me solve the main issue it dont need to abort the event any longer. But perhaps that will be needed in a later scenario. Do you have any idea on how to do it? As you write, returning false won't help. – Mike001 Feb 7 '13 at 12:39
Better add your features to the layer and use a filter to not display them. But it depends on your use case whether this is feasible or not. – ahocevar Feb 11 '13 at 16:51
Sadly thats not possible in this case. – Mike001 Feb 19 '13 at 15:29

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.