my.startCompass
The my.startCompass JSAPI is called by mini program developers to start compass monitoring.
Parameters
Parameter | Data type | Required | Description |
interval | String | No | The execution frequency of the callback functions that monitor compass data updates (the listeners registered with my.onCompassChange). Valid values are:
If not specified, the value defaults to |
success | Function | No | A callback that is executed when the JSAPI call is successful. |
fail | Function | No | A callback that is executed when the JSAPI call fails. When executed, it receives an |
complete | Function | No | A callback that is executed when the JSAPI call completes, regardless of success or failure. |
err
object
Parameter | Data type | Required | Description |
error | Number | Yes | An error code that represents the specific error encountered. |
errorMessage | String | Yes | An error message that describes the corresponding error code. |
Sample code
my.startCompass({
interval: 'normal',
success(res) {
console.log(res)
},
fail(err) {
console.log(err)
}
});