tencent cloud

Tencent Cloud Super App as a Service

Release Notes and Announcements
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
Product Introduction
Overview
Strengths
Use Cases
Purchase Guide
Billing Overview
Pay-As-You-Go Billing
Renewal Guide
Service Suspension Instructions
Getting Started
Plan Management
Overview
Console Account Management
Storage Configuration
Acceleration Configuration
Branding Configurations
Platform Features
Console Login
Users and Permission System
Mini Program Management
Mini Game Management
Superapp Management
Commercialization
Platform Management
User Management
Team Management
Operations Management
Security Center
Code Integration Guide
Getting Demo and SDK
Android
iOS
Flutter
Superapp Server
GUID Generation Rules
Mini Program Development Guide
Mini Program Introduction and Development Environment
Mini Program Code Composition
Guide
Framework
Components
API
Server Backend
JS SDK
Base Library
IDE Operation Instructions
Mini Game Development Guide
Guide
API
Server Backend
Practice Tutorial
Mini Program Login Practical Tutorial
Mini Program Subscription Message Practical Tutorial
Payment Practical Tutorial
Ad Integration Practical Tutorial
Mini Game Subscription Message Practical Tutorial
API Documentation
History
Introduction
API Category
Making API Requests
Operation Management APIs
User Management APIs
Team Management APIs
Sensitive API-Related APIs
Role Management APIs
Platform Management APIs
Other Console APIs
Mini Program or Mini Game APIs
Management-Sensitive APIs
Global Domain Management APIs
Superapp APIs
Data Types
Agreements
Service Level Agreement
Data Processing and Security Agreement
SDK Privacy Policy Module
SDK Data Processing and Security Agreement Module

Compass

PDF
Focus Mode
Font Size
Last updated: 2025-02-24 17:10:36

startCompass

This API is called using wx.startCompass(Object object).
Feature description:Starts listening for compass data.
Parameter and description: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).
Example:
wx.startCompass()

stopCompass

This API is called using wx.stopCompass(Object object).
Feature description:Stops listening for compass data.
Parameter and description: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).
Example
wx.stopCompass()

onCompassChange

This API is called using wx.onCompassChange(function listener).
Feature description:Listens for compass data change event. Frequency: 5 times per second. Automatically starts listening after the API call, and can be stopped using wx.stopCompass.
Parameter and description:function listener. The callback function for compass data change event. Parameter: Object res.
Property
Type
Description
direction
number
The direction in degrees.
accuracy
number/string
The accuracy.
Example
wx.onCompassChange(function (res) {
console.log(res.direction)
})
The accuracy difference on iOS and Android:Due to platform differences, the accuracy has different values on iOS and Android.
iOS: The accuracy is is a number representing the deviation from magnetic north. 0 means the device points to magnetic north, 90 means east, 180 means south, and so on.
Android: accuracy is a string representing an enumerated value.
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.

offCompassChange

This API is called using wx.offCompassChange(function listener).
Feature description:Removes the listener for compass data change event.
Parameter and description:function listener. The listener passed to onCompassChange. If not provided, all listeners will be removed.
Example:
const listener = function (res) { console.log(res) }

wx.onCompassChange(listener)
wx.offCompassChange(listener) // Must pass the same function object used in onCompassChange



Help and Support

Was this page helpful?

Help us improve! Rate your documentation experience in 5 mins.

Feedback