I haven't updated my blog for a long time. I don't want to write, don't want to get it, and I'm lazy.
Today we will introduce the compass.
Compass
Obtain the current orientation of the device. The compass is a sensor that detects the direction or orientation of the device. The measurement unit is degree, and the value ranges from 0 degrees to 359.99 degrees.
There are several methods for this object:
Navigator. Compass. getcurrentheading (compasssuccess, compasserror, compassoptions );
Obtains the current orientation of the compass.
Compass. watchheading
VaR watchid = navigator. Compass. watchheading (compasssuccess, compasserror, [compassoptions]);
Obtain the angle of the orientation of the compass at a fixed interval.
Compass. clearwatch
Navigator. Compass. clearwatch (watchid );
Stop the compass monitoring that the watch ID parameter points.
This is similar to the accelerometer accelerator described earlier, so it will not be explained in detail.
ExampleCode:
<! Doctype HTML>