Error compensation of electronic compass in magnetic heading