I've tried building one of these and the answer is - it's difficult.
There is a message queue that you can use to identify the last reported location of a train. Depending on the line you could get a pretty accurate real-time map (but first you need to georeference all of the location identifiers to eastings/northings.)
But many lines report only the last movement at a station stop - these are mostly in rural areas so the best approach seems to be to build some sort of dead-reckoning network taking into account train type and network utilisation.