A prototype of an in-flight map: the route between two cities on a world map, with the aircraft moving along it and live flight data beside it — time and distance left, speed, altitude and outside temperature.
Demo: flights.adamplesnik.com
Every flight is laid out automatically. The route is drawn on a Web Mercator map, the same projection as Google's and Apple's flat maps, and a solver decides how far to zoom, where the route sits and where the city names and data go, so that nothing overlaps.
- Automatic layout — the largest zoom at which the route, both city labels and the data fit a 48px safe zone, with the data in either a bottom row or a right column
- Any route — great circles by default, or a smooth curve through waypoints; routes across the date line continue onto the next copy of the map
- Playback — play, pause and a scrubbing slider that follows the flight
- Responsive — the controls stack on narrow screens, and the scene scales with its container
- Light and dark mode — following the system setting, through a small set of theme colours
Requires Node.js 22 and pnpm.
pnpm install
pnpm devThe app runs at http://localhost:8443 (or the port in PORT).
| Command | What it does |
|---|---|
pnpm dev |
Development server with hot reload |
pnpm build |
Production build into dist/ |
pnpm preview |
Serve the production build |
pnpm build:lib |
Build the package into dist-lib/ |
pnpm screens |
Remake public/screens/ from screens/positions.mjs, with the dev server running |
pnpm format |
Format the sources with Prettier |
node scripts/generate-world-map.mjs |
Regenerate the world map and country names |
The components are published as flight-progress,
for React 19.
npm install flight-progressimport { FlightMap, FlightPlayer, flights, lisZurich } from 'flight-progress'
import 'flight-progress/style.css'
import 'flight-progress/fonts.css' // unless the page loads Inter 400 and 600 already
// The whole view: the flight's name, the map in a rounded frame, play/pause and a slider
<FlightPlayer flight={lisZurich} />
<FlightPlayer flight={flight} flights={flights} onSelectFlight={setFlight} />
// Only the map, without border or rounded corners: animated, or held at a position
<FlightMap flight={lisZurich} />
<FlightMap flight={lisZurich} progress={0.4} theme="dark" />Both take the full width of their parent, with the map at 4:3. theme is 'system' (the
default), 'light' or 'dark'. progress and initialProgress are shares (0..1) of the
flight's timeline, which includes the time on the ground before take-off and after landing.
The world map, about 1.4 MB, loads as a chunk of its own after the first paint.
The package also exports the flights (flights, each by name, flightById, findFlight),
flightTitle, flightPath and the Flight type, so you can pass in flights of your own.
Screenshots of every flight, 2048 × 1536, are in public/screens/, so the demo serves them at
https://flights.adamplesnik.com/screens/<flight id>.png, for example
lis-zurich.png. They are not part of
the npm package.
screens/positions.mjs sets where each flight is caught, in percent of its timeline, and
pnpm screens (with the dev server running and Google Chrome installed) remakes
public/screens/ from the /capture page.
Bump version in package.json (npm version patch --no-git-tag-version, or minor/major)
and merge it to main. The Publish workflow then publishes
that version to npm, with provenance, and makes a GitHub release v<version> with notes from
the commits since the last one. A prerelease such as 1.0.0-beta.1 goes out under the next
tag. Pushes that don't change the version do nothing.
It publishes through npm trusted publishing, without a token. The package has to exist on npm
for that, so the first version is published by hand (npm publish), and then a trusted
publisher is added on npmjs.com, in the package's settings: GitHub Actions, this repository,
workflow publish.yml.
Each flight is a file in src/data/flights/, listed in src/data/flights/index.ts; the menu
sorts them by title, and defaultFlight sets the one shown first. Each flight has its own
address from its airports' ICAO codes, like /LPPT-LSZH; any other address opens the default.
A flight has:
originanddestination—city, airporticaocode, localtimeand coordinateswaypoints(optional) — points the route passes through, joined by a smooth curveprofile— rows of minutes after take-off, speed, altitude, temperature and remaining distance, one wherever a value changes its course; the values between are interpolatedtimeline— minutes on the ground before take-off and after landing, and taxiing
The flight profiles included are synthetic: plausible climbs, cruises and descents fitted to each route's distance and duration, not recorded flight data.
src/layout/projection.ts— Web Mercator and great-circle mathssrc/layout/computeLayout.ts— the layout solver: tries the row and the column layout, centres the route and city labels in the space left, and keeps the larger zoomsrc/layout/textMetrics.ts— text widths for the solver, measured from the Inter fontsrc/partials/— the scene's components: map, route, city labels, data panel and controlssrc/lib/— the package: its entry,FlightMap,FlightPlayerand stylesheetssrc/lib/style.css— all the styles, in plain CSS nested in.flight-progress, so the package's stylesheet leaves the rest of the page alone. The theme is five--fp-color-*colours, each alight-dark()pairsrc/Capture.tsxandscreens/— the page and script that make the screenshots
React 19, TypeScript and Vite.
- Map data: Natural Earth (public domain), via world-atlas
- Typeface: Inter by Rasmus Andersson
MIT © Adam Plesnik — adamplesnik.com