Device heading relative to the north

How I can know the device heading relative to the north? I tried wit Motion but the heading is relative from the first heading given.
There is any way to build a compass app with ionic and capacitor?

Hey @Xevib0, take a look at this and try this using the raw Web APIs: https://stackoverflow.com/questions/49752559/absolute-device-orientation

I’d not use the Motion plugin for now. We’re taking a look at improving it but it currently doesn’t bind the right events for absolute device orientation needed for building a compass app. It’s more useful for relative motion as you’ve found.

Thank you Max, it worked perfectly so I post the code that I used:

window.addEventListener("deviceorientationabsolute", (e:DeviceOrientationEvent)=>{
	console.log(e);
}, true);
1 Like