Map – Tube & Rail (Geo)
Geographic track for Tube, Elizabeth, Overground, DLR, and Tram.
Preview
MapLibre GL JS on OpenFreeMap Positron (vector). No API key. Station names appear as you zoom.
Usage
Installation
pnpm dlx shadcn@latest add https://tfl.manglekuo.com/r/tfl-geographic-map.jsonThis copies the component, types, and credit helpers. The GeoJSON still has to live somewhere your app can fetch. Copy public/data/geography/*.json into the project, or host those files on a CDN.
Unique corridors, not every variant
OpenStreetMap stores each timetable pattern as its own route. Paint all of them and the Elizabeth line stacks 24 times on the same tracks.
The map draws unique track: directional twins merged into one centreline, real branches kept, junctions welded to a shared vertex. Toggle Both tracks in the preview for each direction as its own polyline. /data/geography/{mode}-graph.json is the same network as nodes and edges. Full OSM variants stay in the repo for analysis — do not put them on the map.
| File | Centreline | Both tracks | OSM variants | Stations |
|---|---|---|---|---|
tube-geometry.json | 28 | 56 | 208 | 270 |
overground-geometry.json | 14 | 27 | 50 | 112 |
elizabeth-geometry.json | 5 | 10 | 24 | 41 |
dlr-geometry.json | 5 | 10 | 12 | 45 |
tram-geometry.json | 4 | 6 | 10 | 38 |
all-stations.json is the same 456 stations with merged line ids. Rebuild unique-track with pnpm geography:unique-track.
Related
Bus routes are a separate map — they come from TfL route sequences, not these vendored rail files. See Map – Bus (Geo). Pass derived dots as vehicles — Live Tube & Rail vehicles places them.
Draw it in your own map
The files are GeoJSON. MapLibre and Leaflet need no key. Mapbox and Google Maps need a token from your project.
MapLibre GL JS
Leaflet
Mapbox GL JS
Needs a public access token.
Google Maps
Needs a Maps JavaScript API key.
Props
TflGeographicMap fills its parent. Give the wrapper a height.
| Prop | Type | Default |
|---|---|---|
| data | Record<TransitMode, Bundle> | fetches vendored JSON |
| modes | TransitMode[] | all five |
| lineIds | string[] | all lines |
| trackModel | "centreline" | "dual" | centreline |
| vehicles | VehiclePosition[] | none |
| showStations | boolean | true |
| showLines | boolean | true |
| showNavigation | boolean | true |
| center | [lng, lat] | [-0.12, 51.51] |
| zoom | number | 10.2 |
| className | string |
Track data still belongs to OSM
Geometry is © OpenStreetMap contributors, ODbL 1.0. Station metadata where present is © Transport for London, TfL Open Data. The Positron basemap is © OpenStreetMap contributors and © OpenFreeMap. The full declaration is data/geography/ORIGIN.md.
In code
Map – Bus (Geo) · Live Tube & Rail vehicles · Cycle hire docks · Schematic & network · Colours