Many traffic occasions such as tunnels, subway stations and underground parking require accurate and continuous positioning. Navigation and timing services offered by the Global Navigation Satellite System (GNSS) is the most popular outdoor positioning method, but its signals are vulnerable to interference, leading to a degraded performance or even unavailability. The combination of magnetometer and Inertial Measurement Unit (IMU) is one of the commonly used indoor positioning methods. Within the proposed mobile platform for positioning in seamless indoor and outdoor scenes, the data of magnetometer and IMU are used to update the positioning when the GNSS signals are weak. Because the magnetometer is susceptible to environmental interference, an intelligent method for calculating heading angle by magnetometer is proposed, which can dynamically calculate and correct the heading angle of the mobile platform in a working environment. The results show that the proposed method of calculating heading angle by magnetometer achieved better performance with interference existence. Compared with the uncorrected heading angle, the corrected accuracy results could be improved by 60%, and the effect was more obvious when the interference was stronger. The error of overall positioning trajectory and true trajectory was within 2 m.