Saturday, June 7, 2008

Hacking GPS and Google Maps

OK, maybe not quite hacking. Still, this is a compendium of things that I have learned about my Garmin Nuvi 770, GPSes in general, and tools that work with them, especially Google Maps. Since half the people I know seem to have a new Nuvi, maybe someone will find some of this useful.

Extracting current data
The current favorites, routes, and so on are always available for export from a file called current.gpx. You could use this data to transfer favorites between units, or to convert favorites to custom POI, or to show your routes in Google Earth, or whatever. A very handy bit of data to be able to get to. As far as I can determine, this file is created exclusively for the purpose of having a generic way to export data so don't edit it. It is my guess that the generation of this file is what is happening when the progress bar is visible after plugging the Nuvi into a computer.

Data Transfer
Almost all of the data that is in the unit can be transferred to an SD card if you want. Including the built-in data. I've been told you can even transfer the maps if you rename them, but I haven't had the courage to try that. Moving data works great with added content, including MadMaps. And of course you can always just put it on the SD card in the first place for things like MP3 and Audible. This is useful because the Nuvi 770 doesn't come with a huge excess of memory.

You can also delete unused language files and other crap from the unit entirely.

Back everything up, of course, or you are an idiot.

Adding Routes
You can add gpx files to the gpx directory, then when you turn on the unit tell it to import the file. These will go into your routes.
Tools/My Data/Import Route from File

GPX file format and Garmin
Garmin has a bunch of extensions to the gpx standard that are worth knowing about. If you format your data this way you can get custom POIs with phone numbers that can be dialed, custom proximity alerts, and so on.

POI display
Custom POI, are never displayed in 3D map view on the Nuvi 770. To see custom POI, you have to be in a 2D view (like "track up") and you have to be zoomed in pretty close (300 ft). Built-in POI are only displayed in map browse view (that might not be the right term, but the view you get when you tap the map and it shows a flat 2D view that doesn't move). Favorites are always displayed, but there is a limit to how many you can have. My wife's StreetPilot has an option to always display icons for custom POI - I miss that option on my Nuvi. It is always fun to drive into Boston and see the approaching cloud of Starbucks.

Google Maps Routes to GPX (with turn by turn routing)
Use this simple javascript tool. This is extremely handy for creating custom routes since you can drag Google Maps routes around until they follow the roads you want. For scenic routes or motorcycle routes or the like, this is your friend.

Google Maps Result Points As Waypoints (favorites, not custom POI)
Use the Google Maps "Send To" function. This requires that you have the Garmin Communicator installed. There is a description of the whole procedure on the Garmin site and a video on YouTube.

Creating custom POI with Google Maps
One of the best ways to create custom POIs is with Google Maps using the My Maps functionality. Suppose that you have a hankering to try out some diners, so you go to Google Maps, center it on your home, and type "diner" into the search box. You pick interesting looking diners from the results, click on the flag on the map and click the "Save to My Maps" link. You might end up with something like this.

The Automated Method

You can automate a lot of the work with TakeItWithMe, which I only discovered after I figured out the whole process. Even using this tool, you may want to clean up some of the text, but it does a decent job.

The Manual Method (for the curious)

Notice that the My Maps page has a link to "View in Google Earth". This is a link to a KML file, but unfortunately it is an indirect KML file. Right-click on this and save a local copy. When you open it in a text editor you will see a line something like:
This is a link to the real KML file, but the link is XML encoded, so you have to clean it up by changing "&amp;" to "&" and so on. You can use the cleaned up URL to get the real KML file.

There are a number of tools that can convert that KML file into something useful. I convert it to a csv file so that I can do some clean up of the text. The combination of a spreadsheet (e.g. Excel) and a text editor that does regular expression search and replace (e.g. jEdit) will make quick work of whatever changes you need to make. Keep in mind that you usually have to swap longitude/latitude columns because the Garmin POILoader expects them in a specific order. In this exercise you are aiming for something that looks like:
-71.6122820,42.2680170,"South Street Diner","40 South St, Westborough, MA 01581 : (508) 870-0101"
-71.4331050,42.2753870,"Lloyd's Diner","184 Fountain St, Framingham, MA 01702 : (508) 879-8750"
-71.1579900,42.3710520,"Deluxe Town Diner","627 Mount Auburn St, Watertown, MA 02472 : (617) 926-8400"
-71.0761800,42.3370780,"Mike's City Diner","1714 Washington St, Boston, MA 02118 : (617) 267-9393"
-71.0576100,42.3496970,"Boston Diner Inc","178 Kneeland St, Boston, MA 02111 : (617) 350-0028"
-71.7924040,42.2603340,"Kenmore Diner","250 Franklin St, Worcester, MA 01604 : (508) 792-5125"
-71.2841490,41.9438210,"Morin's Diner","16 S Main St, Attleboro, MA 02703 : (508) 222-9875"
-71.4843220,41.9914170,"Patriots Diner","65 Founders Dr, Woonsocket, RI 02895 : (401) 765-6900"
-71.5169070,42.1428030,"Ted's Diner","64 Main St, Milford, MA 01757 : (508) 634-1467"
-71.1780010,42.2340240,"50'S Diner","5 Commercial Cir # 101, Dedham, MA 02026 : (781) 326-1955"
-71.0669330,42.3269120,"Victoria Diner","1024 Massachusetts Ave, Boston, MA 02118 : (617) 442-5965"
-71.2310410,42.3770640,"Wilson's Diner Inc","507 Main St, Waltham, MA 02452 : (781) 899-0760"
-71.1220090,42.3907700,"Andy's Diner","2030 Massachusetts Ave., Cambridge, MA 02140 : (617) 497-1444"
-71.8648150,42.1164820,"Carl's Oxford Diner","291 Main St, Oxford, MA 01540 : (508) 987-8770"
-71.4258650,41.8242380,"Haven Brothers Diner","72 Spruce St, Providence, RI 02903 : (401) 861-7777"
-70.9469680,41.8953630,"Dave's Diner","390 W Grove St, Middleboro, MA 02346 : (508) 923-4755"

Now just create a custom icon (if you want) and a custom alert tone (if you want) and load it up with your other custom POIs.

Hacking Sites Using Google API
There are lots of sites these days that are using bits of the Google Maps API. They often have a KML file at the heart of the map they are displaying and you can get at that by looking at the page source. Here is an example from If you look at the source for that page, you will see a reference to this xml (kml) file.

You can obviously directly use this KML file to create POI if you want to, following the manual method I just described.

But you can also do more cool stuff with Google Maps. Copy the URL for the KML file onto the clipboard, open up Google Maps, and paste the link into the search bar. Go ahead, I'll wait. Neat, huh? Believe it or not, this works with Google Maps Mobile on the blackberry as well.

You can also create a My Map based on KML data (create a new map, click the import link, and paste the KML URL or browse to the KML file).


1 comment:

Rozza Jullie said...

Hello. I suggest to try this free tool which lets users to easily convert gpx to kml files or kml to gpx for seeing routes or waypoints in Google Maps.