my.onCompassChange

Use this API to listen to the compass data change event. After the interface call, listening is automatically started. The callback interval is 500ms. You can use my.offCompassChange to stop listening.

Sample Code

copy
my.onCompassChange(function (res) {
  console.log(res.direction);
})

Parameters

The property is a callback function which uses object properties with the following property:

PropertyTypeDescription
directionNumberThe degree of the direction that you are facing.Â