The Zero-velocity Update (ZUPT) aided Extended Kalman Filter (EKF) is commonly used in the classical INS-based PDR system, which can effectively suppress the error growth of the inertial based pedestrian navigation systems. However, the system still suffers from the drift of heading error. The magnetic field is very useful to estimate the heading of the system, but the magnetic disturbance has a severely effect on the estimation. The Quasi-static magnetic Field (QSF) method was developed to estimate heading errors using magnetic field in perturbed environments, but the method may bring extra errors to system as the high false alarm probability of detecting the quasi-static field. In this paper, the improved QSF method is proposed to estimate the heading in the perturbed magnetic field. Also, the improved QSF method is combined with a compass filter, which can successfully extract the desired magnetic measurements and feedback them into the EKF to estimate the heading errors. At last, the iterative 2D map matching method is proposed to refine the trajectory of the PDR system, which can effectively suppress the long-term drift errors of the trajectory. The experiment result shows that the trial trajectory closed error length is 0.109%.