Realtime Boston train map

Animated symbols on a map using Leaflet (open street map) and node.js

This project is under construction:

It uses Leaflet to handle map graphic layers and Stamen for the underlying map.

The data is provided via websockets using a node server

Temporary local files


  • tn.js (background node server: mbta api and websockets)
  • leafredline1.html (handles leaflet code) and must be run on a web server.

After the map loads, scroll down and send the message “go” to open the websocket.


The animation of the train symbols is very primitive. It redraws the entire train line with each polling request.

There are better methods to move symbols on a leaflet map – to be used in subsequent versions.