Skip to content

Instantly share code, notes, and snippets.

@tmcw
Created October 25, 2016 21:01
Show Gist options
  • Save tmcw/96356e828157090ebd243f4e99f65356 to your computer and use it in GitHub Desktop.
Save tmcw/96356e828157090ebd243f4e99f65356 to your computer and use it in GitHub Desktop.
function animate() {
var counter = Math.floor(100 * (Date.now() - start) / duration)
if (counter > 100) return; // the plane is done.
if (destination.length < 3) {
map.getSource('airplane').setData(empty);
return;
}
map.getSource('airplane').setData({
type: 'Feature',
geometry: {
type: 'Point',
coordinates: singleArcCoords[counter]
}
});
requestAnimationFrame(animate);
};
var steps = 100;
var duration = 10000; // 10 seconds
var start = Date.now();
animate();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment