Skip to content

Instantly share code, notes, and snippets.

@aindong
Last active January 25, 2018 08:32
Show Gist options
  • Save aindong/584a156c3a4c2b566e1f2b160b9a6957 to your computer and use it in GitHub Desktop.
Save aindong/584a156c3a4c2b566e1f2b160b9a6957 to your computer and use it in GitHub Desktop.
Google Map Polyline animation
let gpsPath = []
let step = 0
let stepIncrement = 1
let numSteps = locations.length - 1
let timePerStep = 300
let interval = setInterval(() => {
step += stepIncrement
if (step >= numSteps) {
clearInterval(interval)
} else {
let latLng = {
lat: locations[step].lat,
lng: locations[step].lng
}
gpsPath.push(latLng)
center = latLng
}
}, timePerStep)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment