The method of utilizing this API is wx.startCompass(Object object).
Attributes | Types | Default value | Required | Note |
success | function | - | Not required | Successful Interface Call Response |
fail | function | - | Not required | Callback function for unsuccessful interface invocation |
complete | function | - | Not required | Callback function executed upon the completion of the interface invocation (both successful and unsuccessful invocations) |
wx.startCompass()
The usage method for this API is wx.stopCompass(Object object)
Attributes | Types | Default value | Required | Note |
success | function | - | Not required | Callback function for successful interface invocation |
fail | function | - | Not required | Callback function for unsuccessful interface invocation |
complete | function | - | Not required | Callback function executed upon the completion of the interface invocation (both successful and unsuccessful invocations) |
wx.stopCompass()
The usage method for this API is wx.onCompassChange(function callback)
Attributes | Types | Note |
direction | number | Facing direction degrees |
accuracy | number/string | Precision |
wx.onCompassChange(function (res) {console.log(res.direction)})
Value | Note |
high | High Precision |
medium | Moderate Precision |
low | Low Precision |
no-contact | Unreliable, sensor connection lost. |
unreliable | Unreliable, reason unknown. |
unknow ${value} | Unknown precision enumeration value, that is, the value representing precision returned by the Android system at this time is not a standard precision enumeration value. |
The usage method for this API is wx.offCompassChange(function listener).
const listener = function (res) { console.log(res) }wx.onCompassChange(listener)wx.offCompassChange(listener) // The same function object as the listener must be passed in.
Was this page helpful?