About SL Live Map

What it is, and how it works

Svensk version →

The text starts broad and gradually becomes more technical. The first part is enough if you're just curious. The last part is for those who want to know exactly how it's built.

What is this?

SL Live Map shows where Stockholm's public transport is right now. Buses, metro, commuter trains, trams and ferries move across the map in real time. During rush hour, around a thousand vehicles are visible at once.

The map updates every two seconds. Click on a vehicle to see which line it is, where it's heading and how fast it's going.

How did it start?

It started with a simple question: could you build a webpage that shows Stockholm's local transit live on a map?

It turned out that Trafiklab publishes GPS positions for every SL vehicle as open data. A Python server that fetches the feed, an HTML page with a Leaflet map, and coloured dots showing where the vehicles are — that was the first version. It went live on Monday evening, 16 February 2026.

Since then it has gained line colours for metro and commuter trains, station markers and route lines from Trafiklab's GTFS data, and a popup that shows where each vehicle is heading.

Where does the data come from?

Positions come from Trafiklab, which publishes open public-transport data for Sweden. SL's vehicles continuously report their GPS position, and that data is forwarded as an open GTFS feed anyone can use.

Route shapes and station locations also come from GTFS Regional Static, the same source SL's own journey planner uses.

Map of Stockholm's rail network — metro, commuter trains and trams

Some numbers

The server fetches new positions from Trafiklab every two seconds, around the clock. That's about 43,000 calls per day, and each response contains positions for every vehicle in service. In total, around 40 million vehicle positions pass through the system every day.

...
visitors since launch
...
avg. session
...
page views

What's shown on the map?

Each vehicle appears as a coloured dot with the line number in it. The colour shows the mode:

ModeColourLines
Buses SL red ~100 lines
Metro Line colour 3 lines (7 branches)
Commuter rail Line colour 4 lines
Tram Line colour 10 lines
Ferries Cyan ~20 lines

Buses only appear when you zoom in enough — otherwise the map would be unreadable. Metro, commuter trains, trams and ferries are always visible.

Why are some vehicles missing?

Vehicles that don't report their position over GPS aren't shown. That includes vehicles parked in depots or with GPS equipment issues. Vehicles without line information are also filtered out, since there's no way to tell whether they're in service.

Architecture

The whole site is deliberately simple. A Python server, a single HTML file with embedded JavaScript, no framework, no database.

The server is stateless. There's nothing to log into, and no sessions. All data the server holds in memory is a cache of the latest API response plus a lookup table for line info.

Data sources

SourceWhatCalled
GTFS-RT Vehicle positions in real time Every 2 seconds
GTFS Static Lines, stations, route shapes Offline, at build time
SL Transport API Line metadata Cached 1 hour

The lookup table

The GTFS feed only gives a trip-ID per vehicle — not which line it's running or where it's heading. That information lives in trip_lookup.json, a 3.4 MB pre-built file that maps ~95,000 trip-IDs to line numbers, modes and destinations. The file is rebuilt when SL updates its static data, roughly once a month.

Tech stack

ComponentTech
Server Python, Flask, Gunicorn
ClientVanilla HTML, CSS, JavaScript
Map Leaflet 1.9
Map tiles CartoDB Dark Matter
Web server Nginx (cache + proxy)
Hosting Hetzner Cloud, Ubuntu 24.04

Thanks!

A big thank-you to everyone who's sent kind words and gotten in touch. I'm honestly moved and a little surprised by the interest. It really means a lot.

Got a thought, a greeting, or just want to say hi? Drop a line below.