HomeMaps

PreviousNext

Vehicle progress

Place a vehicle between two stops from a 0–1 progress value.

Primitive

Preview

Usage

const progress = progressBetweenStops(timeToNext, timeToFollowing)
const point = pointBetweenStations({ from, to, progress, polylines })

<TflGeographicMap lineIds={["victoria"]} vehicles={[{
  vehicleId: "demo",
  lineId: "victoria",
  lat: point.lat,
  lon: point.lon,
  bearingDeg: point.bearingDeg,
  destinationName: "Brixton",
  timeToNextStationSec: timeToNext,
}]} />

Getting the data

TfL arrivals have no coordinates. line.getArrivals gives timeToStation at each stop. Two times on the same vehicleId become a 0–1 progress value.

progressBetweenStops(30, 90) // 0.5
progressBetweenStops(40)     // 0 — only the next stop is known

Render

pointBetweenStations takes that progress plus two station coordinates and optional route polylines. Pass the point as a vehicles row on Map – Tube & Rail (Geo) or Map – Bus (Geo).

In code

Live vehicles · Map – Tube & Rail (Geo) · Map – Bus (Geo)