Using the Device Compass with PhoneGap


/ Published in: JavaScript
Save to your folder(s)



Copy this code and paste it in your HTML
  1. var watchId = 0;
  2.  
  3. watchId = navigator.compass.watchHeading( function( heading ) {
  4. $( '#compass' ).css( '-webkit-transform', 'rotate( ' + heading.magneticHeading + 'deg )' );
  5. }, function( error ) {
  6. console.log( 'Error' );
  7. }, {
  8. frequency: 100
  9. } );

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.