Skip to navigation

Tubewalker: The Tube, on Foot

About this Site: How I Created My Walking Maps

One of the more enjoyable parts of my walking life comes when I publish the results on the Web. For me, part of the thrill is knowing that I'll be able to go back in years to come and remind myself of the good (or bad) times, and being English, I thoroughly enjoy wallowing in nostalgia. But another happy aspect is when people get in touch and say they really like my site... and then ask, by the way, just how did you create those cool maps showing your walking route?

My Maps

A screenshot showing a route being edited in Google My Maps
Using Google My Maps to create a map of each Tube line, in this case a stretch of the Metropolitan line between Northwood and Northwood Hills

Getting your route online can be a bit of a trauma, especially if you haven't already done your walk and recorded it on a GPS. With this in mind, I designed my tubewalking routes digitally from the start, and to test the process, I started by producing a geographical map of the Tube lines themselves.

Using the Google Maps API

A screenshot showing a walking route being edited in Google My Maps
Editing my walking route along the Piccadilly line west of Boston Manor

But how can you get a route in My Maps onto your own website? The answer lies in My Maps' ability to export your maps to Google Earth. Click on the 'View in Google Earth' link and your browser will save a KML file to your computer that you can load into Google Earth to view your map; look inside this KML file and you'll see a URL pointing to your map on the Google server, and if you replace all the occurrences of & with an unescaped & and then paste the resulting URL into your browser, your browser will save a KML file to your computer containing all the points and routes you've painstakingly entered into My Maps.

Storing Routes in a Database

This system of loading flat XML files into Google Maps works fine, and it's how the maps on my Land's End to John o'Groats site work (though when I digitised these routes, My Maps didn't exist, so I had to write my own, extremely crude version, which did the job, but only at the cost of my sanity). However, things are a little more involved on my Tubewalker site, because I wanted to build a tubewalk planner that could take an arbitrary sequence of Tube stations and output the walking route between them.

Under the bonnet, map.php takes the route parameter and passes it on to another PHP application, map_xml.php, which returns the XML for this route (again, you might have to View Source in your browser to see the XML if you click on this link):

This is passed into the Google Maps API in the same way as the static XML file I used for the geographical Tube map, and it works because the XML loader simply takes a URL as an argument, and it doesn't care whether this points to a static file or dynamically generated XML. I also added shortcuts for the line names, so:

shows the whole Metropolitan line, and I also added in nodes to the dynamic XML for points of interest and photographs. Finally, I coded up a custom map control, the 'Display options' button, that switches the various elements of the map on and off... and that, in a very tight nutshell, is how my maps work.