This mini-project came about because I had a need to give people route instructions for a party.
It’s easy to use Google Maps to set up a customised route by adding placemarks at navigationally-significant locations (see this example), and you can easily add instructions (including pictures) at each point (try clicking on one of the “map pins”).
However in the real world, there is nothing to beat having a list of instructions that each person can print out. I didn’t want to re-type everything into a separate document, so created a web page to extract the key information from Google Maps and present it as a tabular list. Editing the data in Google Maps is immediately reflected in the web page.
There are three key components which are described in more detail (including source listings) on the associated wiki page.
- The KML representation of the map
- A PHP script to pull down the relevant KML file, manipulate it by application of an XSL stylesheet, and create the resulting web page
- The XSL stylesheet
Assumptions and Limitations
- Assumes that the order in which waypoints are added to the Google Map is the correct navigational order. (this could be a real pain if you later needed to add an intermediate point)
- URL transform to get KML file is hard-coded
- Assumes that the only placemarks on the map are navigational waypoints
References
- A lot of the insight on manipulating KML came from Mark Mclaren’s Weblog
- The PHP code to manipulate the XML was heavily lifted from the Zend Developer Zone