1. How do smartphones calculate direction?
Smartphones include a built-in 3-axis magnetometer sensor to measure ambient magnetic field variations. Web applications process relative device orientation angle data via the DeviceOrientation API to determine heading.
2. True North vs. Magnetic North
Compass needles point to Magnetic North rather than geographic True North:
- Magnetic North: The direction aligned with Earth's magnetic field lines, drifting gradually over time.
- True North / Geographic North: The fixed northern point where meridian lines converge at the North Pole.
The angular difference between them is called magnetic declination. For everyday navigation and orientation, Magnetic North provides sufficient accuracy.
Compass FAQ
Q: Why is the compass drifting or pointing in the wrong direction?
This is typically caused by local hard-iron interference. Move away from high-voltage cables, large metal structures, electric motors, or magnetic phone cases (such as MagSafe accessories). Calibrate the sensors by waving your device in a smooth figure-8 pattern in the air.
Q: Why do iPhones / iOS devices prompt for permission?
Starting with iOS 13, Apple requires explicit user permission before websites can access motion and orientation sensor APIs to safeguard user privacy.