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

Do you have an example of how you built your compass?

No , in my case is a simple screen with an svg and rotating it with the data readed

Hello, thanks for this suggestion :slight_smile:
There is just a problem of compatibility for IOS:

I’m still searching for a recent and better alternative to @awesome-cordova-plugins/device-orientation.
I tried the @capacitor/motion but it was not very conclusive (with the latest test) :confused:

Hello,

Is there anything new regarding this?

Maybe a Capacitor package that return the compas information (Absolute/Magnetic North) compatible with both platforms (IOS and Android).

Have a nice day,
Loïc