android - Phonegap compass plugin not working -


i trying compass function working on app no success. judging errors inclined think plugin not being added or device not ready. far can tell have done both things. using phonegap build, code use include is:

<gap:plugin name="org.apache.cordova.device-orientation" version="0.3.9" /> 

which far know required. when click on plugins tab in phonegap build page app shows being there.

watchdirection = null; //phonegap ready var whendeviceready = function(){         console.log("deviceready");         console.log(navigator.compass);         var findmydirection = function(){             console.log("find heading fired");             watchdirection = navigator.compass.watchheading(             //onsuccess             function(heading){                 console.log(heading);                 var magnetdirection = heading.magneticheading;                 $("#movingcompass").css("transform", "rotate(" + magnetdirection + "deg)");             },             //onerror             function(error){                 console.log('code: '    + error.code  +'  message: ' + error.message);             },             //update frequency             { frequency: 1000});         }          findmydirection(); }  //wait phonegap load document.addeventlistener("deviceready", whendeviceready, false); 

the above code works expected exception of compass object. console.log(navigator.compass); returns undefined. , there error on line includes watchdirection = navigator.compass.watchheading( saying uncaught typeerror: cannot read property 'watchheading' of undefined.

it gets listed in phonegap build list of installed plugins, , have geolocation working same code format have posted above.

@marty.h, have working demos here: http://codesnippets.altervista.org/examples/phonegap/demos/public.apps.html go lower half of page , try pre-built app, phonegap-compass-test. if works, top half of page has links github can source code. --jesse


Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - .htaccess mod_rewrite for dynamic url which has domain names -

Website Login Issue developed in magento -