Brave Location Mobile Apps and Web Solutions

Experiments with my Garmin GPS and Windows Live Maps

Originally posted on my old MSDN blog

I love my Garmin 275 nüvi! I’ve always put off buying a SatNav as it somehow seems a sign of weakness to not know where you are, but now I have one I wouldn’t be without it.

What I also like is the integration with Windows Live Maps, in particular the way you can save your collections as Favorites on your device. This makes it trivially easy to find where you’re going to on the site beforehand and then download the location to the GPS.

Communication with the device is handled by a browser plug-in provided by Garmin which can be downloaded from http://www8.garmin.com/products/communicator/

Once the plug-in is installed and the Garmin is connected, then saving a collection to the GPS is as easy as going to the Actions->Send To->GPS menu in the Collections window

The Garmin Communicator Plugin API is available for use on your own website – full details can be found at http://developer.garmin.com/web-device/garmin-communicator-plugin/

There is a great demo page at http://developer.garmin.com/web/communicator-api/apidemo/garminDeviceControlDemo.html which shows all the functionality available via the plug-in, including reading and writing the saved points of interest, and also the tracks of previous journeys made with the GPS.

This is all good stuff, but all the example code uses Google Maps so I thought it might be interesting to adapt the code to get it to work with Windows Live Maps instead.

You can see the results of my experiments on my website at http://www.bravelocation.com/locationdemo and you can see below a screenshot of the page showing my journey home from my office in building 109 in Redmond back to the hotel I’m staying in in Bellevue:

The code is hopefully reasonably understandable and is fairly closely based on the sample Garmin code so I won’t go into too many details here, but here are some of the highlights…

    • There are various issues with the current version of Windows Live Maps in IE8 Beta 1, so you need to run the code in compatibility mode. Rather than expecting the user to know this, I now realise you can force IE into IE7 mode by adding the header
<meta http-equiv="X-UA-Compatible" content="IE=7" />

to the page.

  • When creating a VELatLong object, you need to ensure the latitude and longitude parameters are floats, so I wrapped the parameters in the JavaScript parseFloat() function
  • My only real addition to the Garmin code was to add a “last known location” function to the code. All this does is:
    • Loop through all of the track data on the device
    • Find the track with the latest end date
    • Get the last valid sample location of the latest track
  • I’m only currently using that last known location in the UI, but it won’t take much work to be able to hook this up to be saved at FireEagle – watch this space!

If you’re so inclined, please feel free to use and extend this code however you wish. Let me know if you do, or if you find any bugs!

N.B. This blog post has now moved to https://writingontablets.com