Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
Compass.js - A JavaScript Library To Get Compass Heading On Mobile Phones (ai.github.com)
1 point by Hirvesh on Dec 7, 2012 | hide | past | favorite | 1 comment



via: http://functionn.blogspot.com/2012/12/compassjs-javascript-l...

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.




Consider applying for YC's Fall 2025 batch! Applications are open till Aug 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: