I spent a long time trying to figure out how to animate a symbol on a polyline with the Google Maps API with CSS-style easing functions. I got this to work with this Gist and this Google Maps API example. Now I'm trying to run a setInterval(myFunc, 10)
every ~5 seconds. Here's the relevant code snippet:
function animateCircle(line) {
var count = 0;
let refreshRate = 10;
let countFunc = EasingFunctions.easeInOutCubic;
let perc = 0
function moveCircle() {
count = count < 1 ? (count + 0.005) : 0;
perc = countFunc(count) * 100 <= 100 ? countFunc(count) * 100 : countFunc(count) * 100 - 100
perc = perc >= 0 ? perc : 100 + perc
perc === 0 ? window.clearInterval(moveCircInterval) : ''
// console.log(count + " // " + perc)
var icons = line.get('icons');
icons[0].offset = perc + '%';
line.set('icons', icons);
}
var moveCircInterval = window.setInterval(moveCircle, refreshRate);
window.setInterval(() => moveCircInterval = window.setInterval(moveCircle, refreshRate), 5000)
}
And a full JSFiddle to see it in action.
This code is not great, but nearly working. On my end, it speeds over time, especially if you navigate away from the tab and go back.