Mapping AVC 2013 with Google Static Maps

Note: as of July 2018, Google Static Maps requires an API key.  Links without an API key are now blocked and display an error message.  For details, see Google's Static Maps API.

Most people are familiar with Google Maps, but perhaps you've never heard of Google's "Static Map" API, which is a way to embed maps as rendered images into a web page.  For example, the following image is from Google Static maps and shows the parking lot at Boulder Reservoir where Sparkfun's 2013 AVC will take place.

The URL for this image encodes several factors, such as the center point of the map in GPS latitude and longitude values, zoom level, and many other useful features.  The URL to produce the above image is:

http://maps.googleapis.com/maps/api/staticmap?center=40.071000,-105.229500&zoom=19&size=512x512&sensor=false&maptype=satellite

Breaking this down, you can observe that the Map is centered at 40.071000, -105.229500, is 512 x 512 pixels in size, and is set to zoom level 19, which is two below the maximum zoom availaable (21.)  If you want to know more about generating images like this, see Google's Static Maps API.  Using this API you can overlay markers to show the locations of things such as barrels, hoops and ramps.  For example, here's an image that places 5 makers to show the center of the map as well as the 4 corners of a rectangle centered around this point:

The URL for this image looks like this:

http://maps.googleapis.com/maps/api/staticmap?center=40.071000,-105.229500&markers=color:blue|label:S|40.071000,-105.229500&markers=color:red|label:1|40.070900,-105.229400&markers=color:red|label:2|40.071100,-105.229400&markers=color:red|label:3|40.070900,-105.229600&markers=color:red|label:4|40.071100,-105.229600&zoom=19&size=512x512&sensor=false&maptype=satellite

Breaking this out, here's how the locations of the 5 markers are defined:

markers=color:blue|label:S|40.071000,-105.229500

markers=color:red|label:1|40.070900,-105.229400&

markers=color:red|label:2|40.071100,-105.229400&

markers=color:red|label:3|40.070900,-105.229600&

markers=color:red|label:4|40.071100,-105.229600

Building a Mapping Tool

Next, I decided to write a Java-based program that would download and cache the map data so I wouldn't need an internet connection to access it.  As I worked on this code, it slowly took on new features, with the final result being able to:

Here's a screen capture that shows the program in operation and displaying a Map of the AVC 2013 location with the location of the various obstacles indicated by different colored dots:

The tool palette at the top of the screen works like this:

In addition, the menus at the top provide various options, as follows:

Try it for Yourself

I've attached zipped copies of Mac and Windows executable files below along with the source code, but please read the following notes before you try using the code:

The first time you run the app you'll have a blank Map.  To generate a map for the AVC location (requires an Internet connection), select "Create Map" from the File menu and enter the following data:

Latitude:         40.071

Longitude:    -105.2295

Declination:    9

Map Name:    AVC

Then click OK.  The code will then fetch a complete set of map tiles for all 3 zoom levels (may take several minutes depending upon the speed of your Internet connection.)  Once downloaded, the data will be saved in the following location on your HD, depending on which OS you are using:

    Windows:  C:/Users/~user/Library/GPSTileMap/

     Mac OSX   ~/Library/Preferences/GPSTileMap/

However, you'll only need to know this should you need to delete a map.  Normally, the last generated, or opened map should reopen automatically the next time you start the app.

Uploading Waypoints to Your Rover

I've also attached a simple Arduino sketch named CoordUploadExample.ino below that implements the protocol that runs on the car and receives and saves uploaded waypoint data.  The code contains stub functions at the end of the that you will have to implement to make this code functional.  To give you an example of how this code works, here is an example of what the protocol looks like in action when uploading a series of 5 waypoints, along with a declination value of +9:

z

@0909

$0017E2640CC1472A400157

$0117E24E29C1473723015E

$0217E2576CC1474E81016C

$0317E269B3C14741EE0172

$0417E2666AC14733280161

 And, here the same waypoint data as shown by the "Show Coords" menu selection:

40.0712717,-105.2300736,1

40.0707113,-105.2297437,1

40.0709484,-105.2291456,1

40.0714164,-105.2294675,1

40.0713322,-105.2298456,1