Skip to content

Instantly share code, notes, and snippets.

@garethpaul
Created January 21, 2020 05:10
Show Gist options
  • Save garethpaul/7816c451e67bdd9a055907f4c993d980 to your computer and use it in GitHub Desktop.
Save garethpaul/7816c451e67bdd9a055907f4c993d980 to your computer and use it in GitHub Desktop.
// Setup a line animation for the power to run through e.g. like a strobe..
var animationStep = 30;
function enableLineAnimation(layerId) {
var step = 0;
let dashArraySeq = [
[0, 4, 3],
[1, 4, 2],
[2, 4, 1],
[3, 4, 0],
[0, 1, 3, 3],
[0, 2, 3, 2],
[0, 3, 3, 1]
];
setInterval(() => {
step = (step + 1) % dashArraySeq.length;
map.setPaintProperty(layerId, 'line-dasharray', dashArraySeq[step]);
}, animationStep);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment