[GIS] Deactivating Openlayers Cluster after a certain zoom level

openlayers-2

I want to deactivate the cluster strategy after zoom level 16.
The Cluster strategy gets deactivated and I also change the style of the original features and redraw the layer. But still it takes the styles defined for the clusters instead of taking the newly defined styles.

var test_style = new OpenLayers.Style({
    'fillColor': '#CC66CC',
    'fillOpacity': .8
});
var test_style_map = new OpenLayers.StyleMap({
    'default':test_style
});                  
var test_layer_name=clusterStrategy.layer;
if(zoom_level>16) {
    clusterStrategy.deactivate();
    test_layer_name.styleMap=test_style_map;
    test_layer_name.redraw();
}

Best Answer

A brute force and simple solution can be removing the layer from the map and, after that, adding a new one with the same name which, besides, would use a different style map and would not feature the cluster strategy.