A truck on a delivery run, fed by simulated GPS pings. A Tracker glides
the marker between fixes and keeps a breadcrumb trail; RouteProgress
snaps each position to the planned route, splits it into the travelled and pending
legs, and measures what is left. Hit Follow for the navigation-app
camera: FollowCamera pitches the view and keeps the direction of travel
pointing up, using the same bearing/pitch camera as the 3D tilt example.
tracker.push(latlng) is the whole ingestion API — call it from a
websocket or polling loop. The glide duration should roughly match your ping
interval; a push mid-glide restarts from wherever the marker is.
RouteProgress.update() returns the snapped position, deviation,
distance done/remaining and the route heading; slice() hands back the
two legs as latlng arrays — here they restyle the gray and red polylines every
frame. Give it {corridor: 250} and it fires deviate /
return events for off-route alerts.
FollowCamera drives the same setBearing/setPitch
camera you can control manually — smooth eases the bearing on turns so
the world swings rather than snaps. Following a Tracker (not a bare
marker) gives it exact headings every frame.
DivIcon rotated by
heading − getBearing() — markers billboard upright under pitch, so
screen-space rotation composes cleanly with the camera.