1

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

vectorLayer.removeAllFeatures()

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

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 Dec 9 '12 at 21:27
  • It looks llike you are using BBOX strategy. In your case you should use Fixed strategy. – drnextgis Dec 10 '12 at 1:06
  • Or deactivate your strategy, when you need to use BBOX. – user1702401 Dec 10 '12 at 6:40
  • @Bob can you include the code in your question? It's next to impossible w/o it. – unicoletti Dec 10 '12 at 7:33
2

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

vectorLayer.destroyFeatures();

but then the features have to be recreated.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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