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:
- Internet connection
- Google Maps API key (available for free from Google Maps site, do a search)
- Garmin MapSource (comes bundled with Garmin GPS units)
- Microsoft Excel (XL)
- File Transfer Protocol (FTP) file transfer utility
- Web hosting account (a web site that is hosted for you that you can FTP files to)
- Pure ASCII text editor (I use Windows Notepad)
- Some knowledge of XL
- 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:
- 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.
- Download the sample files from these links:
- Using your HTML editor, open the file “googlemapsample.htm”
- Do a search for “key”
- Replace the sample key with the Google Maps API key you got for free from the Google Maps API web site (do a search)
- On the menu bar at the top of the screen select File and Save
- 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.
- 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
- 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.
- 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.
- On the menu bar at the top of the screen select File and Save As. Name it something appropriate, i.e. gmapswaypoints.
- 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.
- 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.
- 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).
- From the menu bar at the top of the screen select Edit and Copy
- Using XL, open the sample XL workbook named “gpx-to-google-maps-sample.xls”
- Select the “data import 3” tab
- From the menu bar at the top of the screen select Edit and Paste
- Do a File:Save As and name the new file “gpx-to-google-maps-sample-02”
- Select the “data import 3” tab
- 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.
- Select the “conversion to google map” tab
- From the menu bar at the top of the screen select Edit and Replace
- In the “find what” field enter “data import 2”
- In the “replace with” field enter “data import 3”
- Click on the “replace all” button.
- 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.
- 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.
- 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.)
- 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.
- 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.
- 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.
- Select the “conversion to google map” tab
- Using your pure ASCII text editor such as Notepad, open the file gmap-samplepagedata.xml
- Select all the existing marker block data (all the lines that begin with <marker )
- Toggle back to Microsoft Excel
- Go to cell BB:3. Select all the cells down from BB:3 that have valid lat/lon data.
- From the menu bar at the top of the screen select Edit and Copy
- Toggle back to your text editor
- From the menu bar at the top of the screen select Edit and Paste
- In the text editor, select all the existing line block data (all the lines that begin with <point )
- Toggle back to Microsoft Excel
- 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. )
- From the menu bar at the top of the screen select Edit and Copy
- Toggle back to your text editor
- From the menu bar at the top of the screen select Edit and Paste
- From the menu bar at the top of the screen select File and Save
- 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.”
- 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
- The page should load with all the waypoints from your XML file and the photos from your site.
- 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).
- 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.
- 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.
WOW, Doug, this is really interesting and very detailed! Thank you so much, I will give it a try.
Hayden