I have a map (using OpenLayers) and a vector layer containing features(points). Sometimes I need to remove all features from the vector layer. When I use


then it removes all features from only one zoom level. When I change zoom level, I see all my features again. How can I remove all features from all zoom levels?

2 Answers 2


How were the features loaded in the layer in the first place?

Unless the features were added on the client (i.e. in a Javascript function written by you), when the extent changes the default behavior for Vector layers backed by WFS is to fetch new features from the server.

You can customize the behavior of the Vector layer with regard to remote sources by providing a properly configured strategy. Examples like this one are available in the examples page.

  • Yes, added in the client by js function. What strategy in this case should I use?
    – Dmitri
    Commented Dec 9, 2012 at 21:27
  • It looks llike you are using BBOX strategy. In your case you should use Fixed strategy.
    – drnextgis
    Commented Dec 10, 2012 at 1:06
  • Or deactivate your strategy, when you need to use BBOX. Commented Dec 10, 2012 at 6:40
  • @Bob can you include the code in your question? It's next to impossible w/o it.
    – unicoletti
    Commented Dec 10, 2012 at 7:33

Well I had the same problem too and solved it using the function destroyFeatures


but then the features have to be recreated.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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