title: How to animate a line string between 2 points in OpenLayers 3 map?
body: <p>I want to draw a line between multiple points from an array of coordinates.
  <strong>My code looks like :</strong> </p>
  
  <pre><code>&lt;button onclick="drawAnimatedLine(new ol.geom.Point(6210355.674114,2592743.9994331785), new ol.geom.Point(8176927.537835015,2255198.08252584), 50, 2000);"&gt;Draw Line&lt;/button&gt;
  </code></pre>
  
  <p><strong>And my js looks like :</strong> </p>
  
  <pre><code> function drawAnimatedLine(startPt, endPt, steps, time, fn) {
              var style = {
                  strokeColor: "#0500bd",
                  strokeWidth: 15,
                  strokeOpacity: 0.5,
                  strokeColor: '#0000ff'
              };
              var directionX = (endPt.x - startPt.x) / steps;
              var directionY = (endPt.y - startPt.y) / steps;
              var i = 0;
              var prevLayer;
              var lineDraw = setInterval(function () {
                  console.log("Inside Animate Line");
                  if (i &gt; steps) {
                      clearInterval(lineDraw);
                      if (fn)
                          fn();
                      return;
                  }
                  var newEndPt = new ol.geom.Point(startPt.x + i * directionX, startPt.y + i * directionY);
                  var line = new ol.geom.LineString([startPt, newEndPt]);
                  var fea = new ol.Feature({
                      geometry:line,
                      style: style
                  });
                  var vec = new ol.layer.Vector();
                  vec.addFeatures([fea]);
                  map.addLayer(vec);
                  if(prevLayer)
                  {
                      map.removeLayer(prevLayer);
                  }
                  prevLayer = vec;
                  i++;
              }, time / steps);
          }
  </code></pre>
  
  <p><strong>Note : Coordinates will be dynamic but for testing I've passed the sample data in onclick of the button. Please do try to sort out this issue as soon as possible.</strong></p>