I have a button which simulates the heatmap. I use setInterval function when the button onclicked
 <button onclick="setInterval(function(){update_map()},50);">simulate</button>
My function is below:
function update_map(){
  counter+=50;
  var i =1
  for(i=counter-50;i<<?php echo json_encode($lat); ?>.length & i<counter;i++){
  taxiData.push(new google.maps.LatLng(<?php echo json_encode($lat); ?>[i],<?php echo json_encode($log); ?>[i]));
 }
  var pointArray = new google.maps.MVCArray(taxiData);
heatmap = new google.maps.visualization.HeatmapLayer({
    data: pointArray
  });
  heatmap.setMap(map);
  if(i==<?php echo json_encode($lat); ?>.length )
  clearInterval(setInterval(function(){update_map()},50));
}
Any kind of help or suggestion will be appreciated.
 
     
    