Magnetic sensors suitable to detect the earth's field have been available since WWII, and are now commonplace. But Magnetic "North" isn't True North, and varies quitge a lot around the world. In the old days, one took a compass reading, and used a lookup table to determine local Magnetic north, and
another table to calculate True North. Different tables were needed for different locations.
C > D > M > V > T, or T > V > M > D > C, to get Compass from True.
These days, GPS has better long-term directionality when one is moving, but loses heading entirely when one stops.
Why not combine GPS accuracy and location knowlege to compensate for (say) flux-gate compass bearing?
This would allow one to know exact bearing even when stopped for boaters, hikers, etc.