Google Maps and PHP


I’ve kept a map of my travels since around 1999, I used to use the now defunct PARC Xerox Map Viewer, when that went away I started just projecting dots onto XPlanet maps to produce a static map.

Ever since Google introduced their Google Maps system a number of mapping tools became available, dedicated blogs have been written like the very good Google Maps Mania and I’ve been thinking of trying to do my map using that instead.

Gary got hold of some code which got me going but it was a bit of a PITA so some searching brought me to Google Maps EZ which is basically a javascript library that takes standard HTML HREF’s and turns them into points etc, very easy to use.

My problem was still that maintaining data in a html file of HREF’s isn’t exactly what I had in mind, I was more partial to a XML file like the sample below:

<title>Cape Town</title>
<country>South Africa</country>

This contains a lot of information, the type of visit I made to the location, links to my images taken there, a thumbnail to show for the links etc it wouldn’t be great to automate the parsing of that to output the HTML for GMapsEZ?

So that is exactly what I wrote. My script takes a simple configuration file like the one below:

data = visited.xml
type = map
extend = ",-1.241455&spn=3.460112,7.639893&hl=en"
width = 350
height = 200
showcountry = 1
showtype = 0
mapctrl = 1
typectrl = 1
scalectrl = 0
size = small
visit = orange
transit = blue
lived = green

By calling the script I wrote and passing the config file as argument it will produce all the HTML GMapsEZ needs to do its magic.


And this is the map it will produce, this is just a screenshot of the final result, see below the image for a link to the full working page.

My full working version of the map can be seen here, it’s the same data as above just a much bigger map, bigger controls and a different extend. The only actual difference are some changes to the config file, same data and same PHP code was used.

I’ve set up a Wiki to maintain documentation for this as it matures over time, I will make announcements of new features on this blog, but the Wiki will be the resource that contains a always up to date reference to features and installation. You can read about obtaining, configuring and using this script there.