I am using
OpenLayers.Strategy.AnimatedCluster in my application in order to cluster and show points to the end-user. The example is here. All points are located in concrete vector layer. I need to remove all features from that vector layer, but when I use
destroyFeatures then it removes clusters only from the concrete zoom level and if I zoom in and then back I see all my clusters again. How can completely remove them from the map?
I am using
Short answer is:
// Assuming, that clustering strategy is first strategy in your layer vectorLayer.strategies.resolution = -1; vectorLayer.addFeatures();
UPDATE: changing resolution property of clustering strategy will force addFeatures() to redraw features. If you don't do it, features in screen will stay unchanged, until you zoom in or out.
When you are using Clustering strategy, each addFeatures() destroys all previous features. With this command you are destroying old ones and you don't add any new ones.
Clustering strategy holds original features in cache. When you zoom, all objects (features, that represent clusters) in vector layer are destroyed and new clusters are generated from cached features. removeAllFeatures and destroyFeatures remove only clusters, but don't affect original features in cache.