title: OpenLayers. How to refresh cluster?
body: <p>I dynamically add features to my cluster, however, as far as I can see clustering does not work. My layer is defined like so:</p>
  
  <pre><code>var source = new ol.source.Vector({});
  
  var cluster = new ol.source.Cluster({
      distance: 10,
      source: source
  });
  
  var style = new ol.style.Style({
        fill: new ol.style.Fill({
              color: "rgba(255,150,0,1)"
        }),
        stroke: new ol.style.Stroke({
            color: "rgba(255,150,0,1)",
            width: 1
        }),
        image: new ol.style.Circle({
             radius: 1,
             fill: new ol.style.Fill({
                 color: "rgba(255,150,0,1)"
             })
         }),
         zIndex: 1
     });
  
  var layer = new ol.layer.Vector({
     source: cluster,
     style: style,
     zIndex: 1
  });
  </code></pre>
  
  <p>And I add multiple features (Point geometries) in bulk in one of my functions, which take the layer as an argument. It does it like so:</p>
  
  <pre><code>layer.getSource().clear();  
  layer.setVisible(true); 
  layer.getSource().addFeatures(features); // features is a large array of features
  </code></pre>
  
  <p>However, if I zoom in and zoom out, I see these pictures:</p>
  
  <p><a href="https://i.stack.imgur.com/HzPrV.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/HzPrV.png" alt="enter image description here"></a></p>
  
  <p>and:</p>
  
  <p><a href="https://i.stack.imgur.com/kV2XM.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/kV2XM.png" alt="enter image description here"></a></p>
  
  <p>On the second screen shot, you can see, that my layer shows all features and ignores clustering parameter. Why is that and how can I fix it? (PS. If it matters, I'm using the latest version of OL)</p>