This API is used via wx.startCompass(Object object).
Attribute | Type | Default value | Required | Description |
success | function | - | No | Callback function of successful interface call |
fail | function | - | No | Callback Function of Failing Interface Call |
complete | function | - | No | Callback function executed upon the completion of the interface invocation (both successful and unsuccessful invocations) |
wx.startCompass()
This API is used via wx.stopCompass(Object object).
Attribute | Type | Default value | Required | Description |
success | function | - | No | Callback Function of Successful Interface Call |
fail | function | - | No | Callback Function of Failing Interface Call |
complete | function | - | No | Callback function executed upon the completion of the interface invocation (both successful and unsuccessful invocations) |
wx.stopCompass()
This API is used via wx.onCompassChange(function callback).
Attribute | Type | Description |
direction | number | Degree of faced direction angle |
accuracy | number/string | Precision |
wx.onCompassChange(function (res) {console.log(res.direction)})
Value | Description |
high | High Precision |
medium | Medium 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. |
This method is used via 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?