tencent cloud

Feedback

Last updated: 2024-11-21 18:48:11

    starCompass

    The method of utilizing this API is wx.startCompass(Object object).
    Function Description: Initiate the monitoring of compass data.
    Parameters and Description: Object object.
    Attributes
    Types
    Default value
    Required
    Note
    success
    function
    -
    Not required
    Successful Interface Call Response
    fail
    function
    -
    Not required
    Callback function for unsuccessful interface invocation
    complete
    function
    -
    Not required
    Callback function executed upon the completion of the interface invocation (both successful and unsuccessful invocations)
    Sample Code:
    wx.startCompass()

    stopCompass

    The usage method for this API is wx.stopCompass(Object object)
    Function Description: Cease the monitoring of compass data.
    Parameters and Description: Object object.
    Attributes
    Types
    Default value
    Required
    Note
    success
    function
    -
    Not required
    Callback function for successful interface invocation
    fail
    function
    -
    Not required
    Callback function for unsuccessful interface invocation
    complete
    function
    -
    Not required
    Callback function executed upon the completion of the interface invocation (both successful and unsuccessful invocations)
    Example Code
    wx.stopCompass()

    onCompassChange

    The usage method for this API is wx.onCompassChange(function callback)
    Function Description: Monitor the compass data change event. Frequency: 5 times/second. After the interface is called, it will automatically start monitoring. You can use wx.stopCompass to stop monitoring.
    Parameters and Description: function callback, the callback function for the compass data change event. The arguments Object res are as follows:
    Attributes
    Types
    Note
    direction
    number
    Facing direction degrees
    accuracy
    number/string
    Precision
    Example 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.
    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
    Note
    high
    High Precision
    medium
    Moderate 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

    The usage method for this API is wx.offCompassChange(function listener).
    Function Description: Removes the listener function for compass data change events.
    Parameters and Description: function listener, the listening function passed into onCompassChange. If this parameter is not passed, all listening 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