The invention relates to a method for a field compensation of an electronic compass for influences to a geomagnetic field by magnetic objects in the vicinity of the compass, that is done with acquiring a magnetic field value by a magnetic field sensor and acquiring an inclination with respect to level plane by an accelerometer, in a discrete set of multiple orientations of the compass.