October 09, 2006

GPS + Google Maps Mash-up in 42 lines of code

gps-plus.jpg

Here is a quick and dirty hack to perform mobile GPS-referenced Google Map searches on your laptop (e.g., where's the next coffee shop around here?). 42 lines, about half of them comments. I put this small demo together for last weekend's Silicon Valley Code Camp to show how easy it is to get up and running with GPS. Reading the latitude/longitude from the GPS device takes no work at all, most of the code is just concerned with converting the coordinates into the right number format for Google Maps, and finding the web browser on your machine.

Hardware: you'll need a GPS unit that can output data in NMEA format (most do) and some way to connect it to your laptop. I've tested both the el-cheapo Pharos 360, rebranded by Microsoft and distributed in their Streets+Trips package, and the Trimble Lassen IQ USB Eval Kit sold by SparkFun. Both connect via USB and come with a virtual COM port driver. This means that in your code, you can connect to these devices as if they are connected to a regular serial port.

Software: The example is written in Python 2.4 with the pySerial extension for serial communication installed. On Windows, you'll also need pywin32.

View source in HTML
Download source: gps.zip

Posted by Bjoern Hartmann at October 9, 2006 10:03 PM
Comments

Nice job on the script, i really like the lassen eval kits, i bought the logger version and created an nmea>kml script for offline/online use.

sry for the spam ;)
http://gijs.com/?page_id=14

Posted by: Gijs at October 10, 2006 09:54 AM

WHAT A GREAT IDEA!

Posted by: Informativo at October 10, 2006 10:27 AM

WHAT A GREAT IDEA!

Posted by: Informativo at October 10, 2006 10:28 AM

Excellent idea! And with so little code.
Thanks for the article

Posted by: web design uk at October 10, 2006 11:21 AM

Hey not bad. Now if you can rig up a speaker you could have your own personal onstar / tom-tom :)

Posted by: Atari at October 10, 2006 01:53 PM

You don't need no stinkin' coffee shop when you've got EVDO service!

Neat application!

Posted by: Tom at October 10, 2006 03:59 PM

Interesting use of code, I can't wait to try this out! Good work :)

Posted by: Stephen Brown at October 10, 2006 05:28 PM

Bjoern,

Nice job -- the implemenation is nice and the python is clean and simple.

If you're interested, we have a product called Loki (http://www.loki.com) that uses Wi-Fi triangulation to pinpoint a user's location then gives you access to a myriad of location-based services and websites. It is currently implemented as a browser toolbar, but we also have a publicly available SDK that allows users to integrate our location technology into their own applications with just a few lines of code.

You can download the SDK see some of the other cool apps people have built at http://developer.skyhookwireless.com.

If you get a chance to check it out, please send me any feedback you have as we are always looking to improve both products based on our user's feedback.

Best, rs

Posted by: Ryan Sarver at October 10, 2006 06:53 PM

Never thought that it would be so simple.

Posted by: Me at October 10, 2006 06:56 PM

Is there a way to get the latitude/longitude coordinates of an arbitrary point in Google maps? And how do you specify the lat/long in a url reference to google maps?

Posted by: Mabu at October 10, 2006 07:13 PM

here's how you specify lat/long in a URL (centers the map there, but no marker is displayed):

http://maps.google.com/?sll=38.950,-77.383

you can write some javascript using the googlemap API to extract lat/long really easily, but i'm not sure if there's another way.

Posted by: johnny at October 10, 2006 07:46 PM

But you still need network access to get to Google Maps while on the road. Or are you just collecting coordinates for use later?

Posted by: Ernie Oporto at October 10, 2006 08:30 PM

Here's how you specify a google lat/long URL but with a marker and your choice of text displayed:

http://mempark.notlong.com

Posted by: Veljko at October 10, 2006 09:07 PM

Also, to get an arbitrary lat / long more easily than via "Link to this page" on Google Maps, try the excellent http://mapbuilder.net service.

Posted by: Veljko at October 10, 2006 09:10 PM

How does a Newbie like me make this work? I'm lost and I'd really like to be able to use this with my new GPS (included with MS S&T).

Thank you!!!

Posted by: Aaron Merrell at October 11, 2006 12:29 AM

Thats cool, but you need a live internet connection. For live interaction with Google Earth check out geepeeyes at http://geepeeyes.sourceforge.net/.

Posted by: Justin Shaw at October 11, 2006 02:09 AM

This would be PERFECT if there's a way to run it on a PocketPC of some sort. I've got a GPS sleeve, so obviously, USB's out of the question. Said sleeve has a CF slot, so now I just need to do whatever needs Internet access in a free hotspot... (ahem)

Posted by: Jason at October 11, 2006 05:10 AM