How to calibrate any magnetometer when sensor is changing the location?
Use it as a vector, there will be an offset, but it will prevent the yaw drift of the gyro, and can still trim the other 2, You have precision, but not accuracy, e.g. it can return to the same orientation, but it might not be that clean a path away from that orientation. 

Otherwise have it as a background task, when its not in motion and the orientation has changed, used those points to build up a calibration map for the magnetometer,