I know there are two different APIs for getting compass heading in Javascript, one for iOS and one for everyone else, aka android:
- on iOS I request permission, then listen for
deviceorientation
events and snag theevent.webkitCompassHeading
value. - on Android I listen for
deviceorientationabsolute
events and snag theevent.alpha
value.
I have been assuming that this value returns a bearing to magnetic north, and that for mapping purposes, I should adjust, using the geomagnetism
library, to point to true north.
That said, I realized that none of the guides or spec pages that I’ve read confirm this fact… This leaves me with two questions:
- Is the
deviceorientation::webkitCompassHeading
value relative to magnetic north, or has it already been compensated to true north? - Is the
deviceorientationabsolute::alpha
value relative to magnetic north, or has it already been compensated to true north?
I know the adjustment is likely too small to matter compared to the inaccuracy of the compass itself (at least for most populated areas), but I wanted to know for sure.