I looked into the gtfs (gtfs.org) a while ago. This is a data feed format (protobuf based) that a lot of sites like this use for both schedules and real time updates that is pretty widely adopted. Most gtfs location feeds require getting an API key. But there are a handful of public ones that share actual location updates without that.
This is also how e.g. Google maps and others integrate schedule information for public transport as well.
Building a map from the real time updates is relatively straight foward once you have access.