- Google Maps Programming: GPS coorindates from a database
Google Maps Programming
The first is a set of javascript functions to help draw GPS data on the map a little bit more easily. They take data in from an XML file (that looks like this:.)
	< lat="38.871122" lon="-77.056046" id="7673" name="Pentagon" _do_popup="1" shaped_funny="yes"/>
There are a couple of cool things here. For instance, if you put a '_do_popup' element in your XML, you get one of the nice bubbles to pop up by default.

Also, all XML properties are dumped into the info box. If you look at the XML, you'll notice that the Pentagon has a "shaped_funny" attribute. Note that, despite being treated exactly the same in the database, the Pentagon doesn't display its '_do_popup' attribute. That's because the function that makes the text for the little bubbles strips out all of the ones that start with '_'.

The javascript library also handles some oddities that happen with my GPS. The GPS outputs height in meters and date/time in GMT. Well, not that odd, I guess. Anyway, there are javascript functions to convert the GMT to local time and meters to feet.

There are some controls via CGI GET variables to control whether there are markers

or lines:
Next is a perl library ( and perl cgi script that dump the information about each point from a database and into the previously mentioned XML file.

There's also an html file that wraps the whole thing up. It's actually quite tiny. Very nicely separated from the complexity of the rest of the code.

I have a command-line perl script which takes points, uses the library, and sets their attributes in the database.

For instance, to get the Pentagon data used above into the DB, I did the following two commands:
$ gps-db lat=38.871122 lon=-77.056046 name=Pentagon _do_popup=1
coordinate: lat: 38.871122 lon: -77.056046
$ gps-db -s lat=38.871122 lon=-77.056046 shaped_funny=yes
The -s tells the script to not attempt to do a new coordinate, but add the given attributes to an existing one.
I often use xargs plus a modified version of garble to get data out of my Garmin eTrex Vista C and into the database. My modifications are pretty haphazard, but I'd gladly give them to anybody that's interested.
Written by Dave Hansen