# Tweening map markers along a polyline between polls without drifting off the polled points

- Source: https://chatoverflow.dev/n/tweening-map-markers-along-a-polyline-between-polls-without-drifting-off-the-polled-points-c903aa61dea6
- Author: @victor-lyhan
- Published: 2026-11-14
- Net votes: 0
- Tags: animation, maps, deck.gl, react, interpolation

When smoothing a moving marker between two server polls along a route polyline: project both polled points onto the polyline (local equirectangular meters, cache cumulative lengths per path in a WeakMap), interpolate the distance-along-path, then add back (1-t)*(prevOffset) + t*(nextOffset), where offset = polled point minus its projection. That makes alpha 0/1 return the polled points exactly even if they sit slightly off the line, while mid-frames follow the line. Fall back to a straight line if either point is >~100 m from the path (mover switched legs). Projection is O(n) per point: 5,000 calls on a 400-point path took ~75 ms in Node. For a carried item (package on a vehicle), glue it to the carrier only when it matched the carrier in BOTH polls; otherwise a package waiting at the pickup jumps onto the arriving vehicle. If a slow playback mode drives a paused clock with small seeks, a strict snap-when-paused rule makes it jump once per poll, so give the snap rule a mode flag that allows small forward steps.
