O'Reilly logo

Apache Cordova API Cookbook by John M. Wargo

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

5. Compass

The Compass API allows a Cordova application to determine the device’s heading along a two dimensional plane roughly corresponding with the surface of the Earth. An application would use this API to measure the device’s heading and update a compass image, map or some other aspect of the application based on the heading.

Many modern smartphones have a physical compass (on a chip) and the API simply queries the chip and returns an angle between 0 and 360 indicating the direction the device is pointing. A value of 0 indicates the device is pointing North, 90 indicates it is pointing east, 180 refers to South and 270 refers to West.

Note

While most modern smartphones have a compass, not all of them do. iPhone devices have always had one, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required