
Compass.js - A JavaScript Library To Get Compass Heading On Mobile Phones - Hirvesh
http://ai.github.com/compass.js/
======
Hirvesh
via: [http://functionn.blogspot.com/2012/12/compassjs-
javascript-l...](http://functionn.blogspot.com/2012/12/compassjs-javascript-
library-to-get.html)

Info: Compass.js allows you to get compass heading in JavaScript. Today we
haven’t any standard way to get compass data, but there are two proprietary
APIs and one hack:

\- PhoneGap has navigator.compass API.

\- iOS Safari adds webkitCompassHeading property to deviceorientation event.

\- We can enable GPS and ask user to go forward. GPS will send current
heading, so we can calculate difference between real North and zero in
deviceorientation event. Next we use this difference to get compass heading
only by device orientation.

This library hides all this magic and APIs from you, auto-detects available
way and provides clean and simple API for your geolocation web app.

