raw code

GPS is probably the best known global positioning system, even if there are other countries besides America who built up their own, like Europe with Galileo, Russia with GLONASS and the newest, BeiDou in China. All are based on the same technique, a triangulation of spheres, whose radius is the signal transfer time, given by an atomic clock on the satellite. In general, the more satellites you use this way, the better the accuracy of the determination of the location and some receivers already combine the varying systems. For the original GPS system, 24 satellites orbit around the earth on 6 ecliptic. Every such plane is rotated about 55° to the equator, which result in a dense net around the world, which allows the view to at least 4 satellites at any time from any point on the earth (except the poles).

The hard part in any case is done by the GPS receiver, which interprets the signals and either returns the data in binary form, or the more common NMEA protocol. I wrote a NMEA implementation in JavaScript, which does a lot of nasty work for you. Most NMEA implementations do not much for you, they split the string and you still have to know NMEA at great detail on how to work with the data. GPS.js on the other hand does a little more. It normalizes the data and keeps a state object, which represents the latest information of the position, the errors, the time and satellite positions.

Download GPS.js

Visualizing GPS information

The library comes with quite some examples, like visualizing the current position on Google Maps or displaying the current information on a dashboard with information about the orbital satellite position, the signal strength of each satellite and what state was established during the last received messages.

GPS Dashboard

If you got a receiver lying around, just fish it out of your electronics box and try it yourself. If you still need a receiver, I can recommend this one as a cheap starting option or if you can work with a soldering iron, I recently published an article about the NEO6Mv2 module.

More information and code snippets can be found on Github!