sr71.net - Google Maps Programming: GPS coorindates from a database
Google Maps Programming
The first is a
draw GPS data on the map a little bit more easily.
data in from an XML file (that
looks like this:.)
- Automatic map zooming to fit all markers and tracks.
- wrap the setting up of markers and XML parsing
- converting the XML NodeList to an array
- More GBounds functionality. Compare two GBounds points and
see if one completely spans another.
- Produce an average from a set of GPoints (used in map centering)
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.
< lat="38.871122" lon="-77.056046" id="7673" name="Pentagon" _do_popup="1" shaped_funny="yes"/>
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 '_'.
height in meters and date/time in GMT. Well, not that odd, I guess. Anyway, there are
There are some controls via CGI GET variables to control whether there
Next is a perl library (gpsdb_pl.pm) 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 gps_db.pm library, and sets their attributes in the
For instance, to get the Pentagon data used above into the DB, I did the following
The -s tells the script to not attempt to do a new coordinate, but add the
given attributes to an existing one.
$ 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
I often use xargs plus a modified version of
garble to get data out
Garmin eTrex Vista C and into the database. My modifications are
pretty haphazard, but I'd gladly give them to anybody that's interested.