Javascript on Chrome - How to get correct heading values from the deviceorientationabsolute event?

Viewed 353

I am trying to retrieve absolute heading values in Google Chrome on Android using javascript for a web app which uses geo location.

I am listening to the new deviceorientationabsolute event:

if ('ondeviceorientationabsolute' in window) {
   window.addEventListener("deviceorientationabsolute", ondeviceorientationabsolute, true);
} 
else if ('ondeviceorientation' in window) {
   window.addEventListener("deviceorientation", ondeviceorientation, true);
} 

The corresponding method gets called successfully:

if (event.absolute  === true) {
     if (event.alpha === null) {
        return;
     }

     console.log('absolute: ' + event.absolute)     // true
     console.log('alpha: ' + event.alpha)           // 0.00 (at the start)
}

But this gives me the current relative alpha value instead of the absolute one, even though event.absolute resolves to true. This means, it behaves exactly like the default deviceorientation event.

Any ideas why this does not behave as expected?

0 Answers
Related