I am wondering how compass calibration works / why e.g. drawing an 8 or rotating the phone to all 3 axis works (or at least shall work) - I mean I would understand the calibration process, if an application would say me: Point to north, then press that button down there, but you can start at basically zero knowledge for the app, just by rotating your phone! How is that done? Also, do I need to enter a special calibration mode or can I draw these figures (like the 8) directly in Google Maps? How does Google Maps know that I am not just really moving the phone but want to calibrate the compass? Thanks for any hint!
Compass calibration works by detecting the magnetic field intensity of earth. But sometimes due to strong interference from other electronic devices like transformers compass sensor may get wrong idea about the magnetic poles of earth and can point in wrong direction. So to ensure that it asks users to recalibrate compass by rotating in figure 8 direction so that it can judge the magnetic intensity in all directions and then from that data it deduces the actual poles of earth.
At any point in space, the magnetic field strength and direction is the net effect of all the magnetic field sources affecting that point. The earth's magnetic field is one of them. Magnetized screwdrivers, cars, refrigerator magnets, etc. all produce fields. Fields are also produced by current flowing through wires. It's like pouring water into a glass from multiple sources. Once it's in the glass, you can't tell where it came from.
There is no instrument that can determine the "actual poles" of the earth by measuring the magnetic field at a point. What the phone can do, however, is sense the point where the phone axis is parallel to the N/S magnetic force line and determine which end of the phone is north-pointing. If you do your dance far away from objects that might be magnetized, like cars and steel fences, the field the phone is measuring MAY be primarily the earth's field and hence the phone compass will be properly calibrated. If you then put the phone into a magnetized car, however, it will point the wrong direction for north. The steel in every car is magnetized to one degree or another.
High-precision compasses such are used on aircraft and serious maritime vessels actually have tiny correction magnets that are adjustable with screws for N/S and E/W errors. They are calibrated after installation by turning the vehicle onto known headings (a compass rose painted by a surveyor on a taxiway far from metal buildings, for example) and fussing with the magnets until the compass error is minimized. Then the residual errors are recorded on a "compass correction card" for use in correcting the indicated readings. Google for "compass correction card" to see images.
In theory, the gps could be used to calibrate the compass when walking or driving since the instantaneous GPS track is accurate. I have not heard of this being done, though it possibly is common. It would work even in a magnetized car. In an airplane or a ship this wouldn't work, however, because the vehicle's heading is to one degree or another usually crabbed slightly into the wind and the GPS has no knowledge of this.