[GIS] OpenLayers vector layer remove all features

featuresjavascriptopenlayers-2

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?

Best Answer

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.