tencent cloud

Feedback

Last updated: 2024-03-04 23:07:53

    starCompass

    This API is used via wx.startCompass(Object object).
    Feature Description: Starts monitoring compass data.
    Parameter and Description: 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)
    Sample Code
    wx.startCompass()

    stopCompass

    This API is used via wx.stopCompass(Object object).
    Feature Description: Stops monitoring compass data, a method used as:
    Parameter and Description: 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)
    Sample Code
    wx.stopCompass()

    onCompassChange

    This API is used via wx.onCompassChange(function callback).
    Feature Description: Monitors compass data change events. Frequency: 5 times/second. After the interface is called, it will automatically start monitoring. You can use wx.stopCompass to stop monitoring.
    Parameter and Description: Function callback.
    Callback function parameters for compass data change events: Object res.
    Attribute
    Type
    Description
    direction
    number
    Degree of faced direction angle
    accuracy
    number/string
    Precision
    Sample Code
    wx.onCompassChange(function (res) {
    console.log(res.direction)
    })
    Difference of accuracy in iOS/Android: Due to platform differences, the value of accuracy varies between iOS and Android devices.
    iOS: Accuracy is a numerical value representing the deviation relative to the Magnetic North. 0 indicates the device is pointing towards the Magnetic North, 90 indicates East, 180 indicates South, and so forth.
    Android: Accuracy is an enumerated value of string type.
    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.

    offCompassChange

    This method is used via wx.offCompassChange(function listener).
    Feature Description: Removes the listener function for compass data change events.
    Parameter and Description: function listener, the listener function passed in by onCompassChange. If this parameter is not passed in, all listener functions will be removed.
    Sample Code
    const listener = function (res) { console.log(res) }
    
    wx.onCompassChange(listener)
    wx.offCompassChange(listener) // The same function object as the listener must be passed in.
    
    Contact Us

    Contact our sales team or business advisors to help your business.

    Technical Support

    Open a ticket if you're looking for further assistance. Our Ticket is 7x24 avaliable.

    7x24 Phone Support