Announcement: Tencent Cloud Mini Program Platform Renamed to Tencent Cloud Super App as a Service on January 2, 2025
Console Updates
Android SDK Updates
iOS SDK Updates
Flutter SDK Updates
IDE Updates
Base Library Updates
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
Was this page helpful?
You can also Contact sales or Submit a Ticket for help.
Help us improve! Rate your documentation experience in 5 mins.
Feedback