How To Create Route Maps

April 16, 2008 – 15:32

Garmin GPS to Google Earth
 
For this task I use GPSBabel, a great little donateware utility, to generate the Google Earth KML files from GPX files created by Garmin Mapsource. The procedure for creating the GPX files from Mapsource is detailed in the next section.
 
 
 
GPS waypoints and associated photos to Google Maps
 
Let me begin by saying there have got to be better, more automated and more professional ways to go about getting waypoints from your GPS and associated photos into Google Maps than my method.
 
Second disclaimer: The days of my putting food on the table by writing code are long past. These days I teach myself as much as I need to get something to work and stop right there. Consequently, my method for this process grew, bit by ugly bit, out of necessity, and was never intended for anything but internal use. My process is, unfortunately, a world class kludge and requires some manual steps.
 
If you do a search on “gpx to google maps conversion” you will get a lot of hits. There are also lots of things that put up geocoded photos into Google Maps, so I would guess someone has built a decent solution for this by now.

If you still want to try it this way, click the "Read the rest of this entry" link below.


 
Required resources:
  1. Internet connection
  2. Google Maps API key (available for free from Google Maps site, do a search)
  3. Garmin MapSource (comes bundled with Garmin GPS units)
  4. Microsoft Excel (XL)
  5. File Transfer Protocol (FTP) file transfer utility
  6. Web hosting account (a web site that is hosted for you that you can FTP files to)
  7. Pure ASCII text editor (I use Windows Notepad)
  8. Some knowledge of XL
  9. Ability to do some simple edits of HTML via an HTML editor such as Front Page or with a simple text editor.
 
Here’s the overview of how to do it using my method and the sample files:
  1. Create 150 pixel and 800 pixel versions of the photos for your waypoints. Copy the photos into separate folders/subdirectories on your photo hosting site or web server, i.e. www.myphotos.com/waypoints/150 and www.myphotos.com/waypoints/800.
  2. Download the sample files from these links:
    1. http://www.hackneys.com/travel/gps/googlemapsample.htm
    2. http://www.hackneys.com/travel/gps/gmap-samplepagedata.xml
    3. http://www.hackneys.com/travel/gps/gpx-to-google-maps-sample.xls  
  3. Using your HTML editor, open the file “googlemapsample.htm”
  4. Do a search for “key”
  5. Replace the sample key with the Google Maps API key you got for free from the Google Maps API web site (do a search)
  6. On the menu bar at the top of the screen select File and Save
  7. Using your File Transfer Protocol (FTP) utility, copy the files “googlemapsample.htm” and “gmap-samplepagedata.xml” to your web server. They need to be in the same folder/subdirectory.
  8. Open your web browser and enter the address to your web hosting site and the sample htm page, i.e. www.mywebsite.com/ googlemapsample.htm
  9. The page should load with all the waypoints from the file and the photos from our site. If it loads, you are ready to begin customizing it for your waypoints and photos. If it doesn’t, you’ll need to sort out why it’s not working before proceeding. We will assume joy.
  10. Using Garmin Mapsource, open the GPS file you want to use to build your Google Map. Delete all unneeded waypoints, all tracks and all routes. Leave only the waypoints you want on the map.
  11. On the menu bar at the top of the screen select File and Save As. Name it something appropriate, i.e. gmapswaypoints.
  12. Now do another File and Save As and export the file as a GPX format file. Use the Garmin Mapsource "Save As" command and select the GPX file format from the drop down list. If it is a big file with a lot of waypoints it will take a while for Mapsource to process and output the file.
  13. Open the GPX file using Microsoft Excel (XL). When prompted, select “Open as XML list.” XL will probably report some errors or difficulties opening the file. You can ignore those and just click “OK” or “continue.” You will probably need to be connected to the internet to successfully load the file. XL needs to look up some reference XML layout data online to know what the GPX file is supposed to look like in XML.
  14. Once the file is loaded into XL, select the entire worksheet by clicking on the intersection box in the upper left corner (left of A and above 1).
  15. From the menu bar at the top of the screen select Edit and Copy
  16. Using XL, open the sample XL workbook named “gpx-to-google-maps-sample.xls”
  17. Select the “data import 3” tab
  18. From the menu bar at the top of the screen select Edit and Paste
  19. Do a File:Save As and name the new file “gpx-to-google-maps-sample-02”
  20. Select the “data import 3” tab
  21. In column AD, edit out all ()[]&’ " characters in the waypoint comments. The map will not work if you have any non alphanumeric characters in the text. If you have carriage return / line feeds, delete those. You want one continuous string of characters for the comment.
  22. Select the “conversion to google map” tab
  23. From the menu bar at the top of the screen select Edit and Replace
  24. In the “find what” field enter “data import 2”
  25. In the “replace with” field enter “data import 3”
  26. Click on the “replace all” button.
  27. Do a File:Save As and name the new file “gpx-to-google-maps-sample-03” As you work through the next section, just like voting on election day in the old days of Chicago, save early and save often. Increment your file number every time you save, that way you can always go back to the previous version.
  28. At this point you’ve got your GPS waypoints loaded into the conversion XL sheet. You will now need to customize the sample XL worksheet to work with your GPS waypoint data and your photos. The first step is the waypoint name. I name my waypoints starting with my initials, a space and then the date (this is because I integrate them into a collection of South American waypoints with other people’s waypoints). I strip out the initials and format the date in columns E and F. If you use a different format for your waypoint name or want to use the actual waypoint date for the Google Map waypoint name you’ll need to change those formulas to match your needs.
  29. The next step is to load the file names for the photos that match your waypoints. The system is built to handle two photos per waypoint. That data is stored in columns G and H. If you don’t have a photo for a waypoint then leave the cell blank. (Tip: I use RoboGEO to geocode photos. You can copy a listing of your photos’ names from the grid in that software to a text editor and easily edit a list of names that pastes directly into the column in XL.)
  30. Columns I and J hold the base web address for the folders containing your thumbnail and full size photos. Copy the address down for all the rows required for your waypoints. Yes, you are right, this is a very kludgey spreadsheet.
  31. Check the “conversion to google map” worksheet to ensure that there are enough rows with formulas to handle all of the rows in your “data import 3” worksheet. If not, select a row in the “conversion to google map” worksheet from A to BC and copy it down as required.
  32. Do a File:Save As and name the new file “gpx-to-google-maps-sample-XX”, where XX is the next numeric increment in your file names.
  33. Select the “conversion to google map” tab
  34. Using your pure ASCII text editor such as Notepad, open the file gmap-samplepagedata.xml
  35. Select all the existing marker block data (all the lines that begin with <marker )
  36. Toggle back to Microsoft Excel
  37. Go to cell BB:3. Select all the cells down from BB:3 that have valid lat/lon data.
  38. From the menu bar at the top of the screen select Edit and Copy
  39. Toggle back to your text editor
  40. From the menu bar at the top of the screen select Edit and Paste
  41. In the text editor, select all the existing line block data (all the lines that begin with <point )
  42. Toggle back to Microsoft Excel
  43. Go to cell BC:3. Select all the cells down from BC:3 that have valid lat/lon data. (Tip: The box around the valid BB column cells will still be there from the previous copy operation and that will tell you where to stop selecting the cells in column BC. )
  44. From the menu bar at the top of the screen select Edit and Copy
  45. Toggle back to your text editor
  46. From the menu bar at the top of the screen select Edit and Paste
  47. From the menu bar at the top of the screen select File and Save
  48. Using your FTP utility, copy the file “gmap-samplepagedata.xml” to your web server. It needs to be in the same folder/subdirectory as the file “googlemapsample.htm.”
  49. Open your web browser and enter the address to your web hosting site and the sample htm page, i.e. www.mywebsite.com/ googlemapsample.htm
  50. The page should load with all the waypoints from your XML file and the photos from your site.
  51. If the waypoints and lines fail to load it is probably because you have a non-alphanumeric character in one of your waypoint comments. To troubleshoot, try copying just two lines of waypoint and line data into your XML file and copy that file to the web server. If those display properly, that tells you the system and files are all working and the problem is in one of the lines of marker or line code. If I have a problem I usually test ten or twenty lines of marker and line code at a time until I identify the problem line(s).
  52. The system should yield a Google Map centered over North and South America displaying your waypoints and a route line between them. If you click on a waypoint marker it will display the waypoint name, the lat/lon, up to two thumbnail photos and a comment. If you click on the thumbnails the 800 pixel image (or whatever size you made them) will open in a new browser window. A drop down list to the right of the map enables direct access to any waypoint.
  53. To change the default start position and zoom level of the Google Map, open the googlemapsample.htm with your HTML editor. Do a search for “create the map.” Edit the line: map.setCenter(new GLatLng(13, -81), 2, G_HYBRID_MAP); The values 13, -81 are the lat/lon of the map start position. The value 2, is the start zoom level. The G_HYBRID_MAP value sets the start display of the map to a hybrid combination of map and sat photo.
 

 Notes:

  • If you make a change to the HTML file, i.e. googlemapsample.htm, and upload the new version to your web server, you will need to force a refresh in your browser to see the new version. On a PC, hold down the CNTRL key and hit the F5 key to force a refresh.
  • If you make a change to the XML data file, i.e. gmap-samplepagedata.xml, and upload the new version to your web server, will need to close all instances of your web browser and open a new session with it to force a refresh of the XML data. In other words, to see your changed or updated map waypoint and route data, close all of your open web browser sessions, then re-open your browser and re-load the route map page.

 

 
  1. One Response to “How To Create Route Maps”

  2. WOW, Doug, this is really interesting and very detailed! Thank you so much, I will give it a try.
    Hayden

    By Hayden Cochran on Apr 16, 2008

Sorry, comments for this entry are closed at this time.