[GIS] Dynamically adding features with cluster strategy

clusteringdynamicfeaturesopenlayers-2vector

I am trying to dynamically add features to a vector layer, and use cluster strategy to group those features accordingly.

I am able to do this for the first set of data that gets loaded on the map.

It looks like below code works only the first time –
vectorLayer.addFeatures(vectordArray);

when i try to call the same addFeatures again with a new set of vectors, I dont see the new vectors. There are no errors either.

Anyone faced a situation like this? I am looking to dynamically add vectors and use CluseterStrategy.

Best Answer

did you try to update your vector layer after this vectorLayer.addFeatures(vectordArray) as shown at following code:

vectorLayer.redraw();

if this not work try to get all features from map into an array and then merge them with your new array then add them to map as if you are adding first time into map...

vectorLayer.removeFeatures(vectorLayer.features);
vectorLayer.addFeatures(newFeatures);

beside this checking out this example here may be helpful for you... it is working on the same principle as your will.

i hope it helps you...