This API is called using wx.startCompass(Object object).
Property | Type | Default value | Required | Description |
success | function | - | False | Callback function for successful API calls. |
fail | function | - | False | Callback function for failed API calls. |
complete | function | - | False | Callback function executed after API call ends (regardless of success or failure). |
wx.startCompass()
This API is called using wx.stopCompass(Object object).
Property | Type | Default value | Required | Description |
success | function | - | False | Callback function for successful API calls. |
fail | function | - | False | Callback function for failed API calls. |
complete | function | - | False | Callback function executed after API call ends (regardless of success or failure). |
wx.stopCompass()
This API is called using wx.onCompassChange(function listener).
Property | Type | Description |
direction | number | The direction in degrees. |
accuracy | number/string | The accuracy. |
wx.onCompassChange(function (res) {console.log(res.direction)})
Value | Description |
high | High accuracy. |
medium | Medium accuracy. |
low | Low accuracy. |
no-contact | Unreliable. The sensor connection is lost. |
unreliable | Unreliable for unknown reasons. |
unknow ${value} | Unknown accuracy enumeration value, meaning the value returned by the Android system is not a standard accuracy enumeration value. |
This API is called using wx.offCompassChange(function listener).
const listener = function (res) { console.log(res) }wx.onCompassChange(listener)wx.offCompassChange(listener) // Must pass the same function object used in onCompassChange