The cause might be a magnet on the case, a nearby metal object or radiation source. Remove the source of the problem and proceed to make a compass calibration following these instructions.
The position arrow spins wildly
Frequently asked questions for CoMaps application