Compass

The compass plugin provides access to the device's compass in order to detect the direction (heading) that the device is pointed to (the compass measures the heading in degrees from 0 to 359.99, where 0 represents north). In order to use the compass in our Apache Cordova project, we need to use the following cordova plugin add command:

>cordova plugin add https://git-wip-us.apache.org/repos/asf/cordova-plugin-device-orientation.git

Demo

In order to access the compass demo, you need to click on the Compass list item. You will be introduced to the Compass page. Then, you can click on the Start Watch Heading button in order to start watching the compass heading. You will be able to get the heading value, as shown in the following screenshot: ...

Get JavaScript Mobile Application Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.