CompassLib

This library provides access to the compass of the device. The compass is a sensor that detects the direction or heading that the device is pointed to, typically from the top of the device. It measures the heading in degrees from 0 to 359.99, where 0 is the north.

Record

Heading indicates compass data.

magneticHeading float
The heading in degrees from 0 to 359.99 at a single moment.
trueHeading float
The heading relative to the geographic North Pole in degrees from 0 to 359.99 at a single moment.
headingAccuracy float
The possible deviation in degrees.
h_timestamp timestamp
The timestamp of the compass.
CompassOption, the option for watching compass.
frequency int
The interval to get compass data in millisecond.
filter float?
The change in degrees required to trigger an onSuccess callback. When this value is set, frequency is ignored.
Functions
getCurrentHeading (onSuccess CompassSuccess in, onError CordovaErrorHandler in)
Gets the current compass and returns to the onSuccess.
onSuccess
The success callback of CompassSuccess, with the compass data passed in.
delegate CompassSuccess(heading Heading in) end
onError
The error callback function.
watchHeading (onSuccess CompassSuccess in, onError CordovaErrorHandler in, options CompassOption in) returns(String)
Retrieves the compass of the device at a regular interval and executes the onSuccess callback function each time. It returns the watch ID which can be used to clear the watch.
onSuccess
The success callback.
onError
The error callback function.
options
An instance of CompassOption to identify the watch interval or filter.
clearWatch(watchID String in)
Stops watching compass.
watchID
The watch ID of the watch that is stopped.