Phonegap entry-8 compass

Source: Internet
Author: User

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> 

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.