The objective of pose graph optimization is to estimate the robot trajectory from the constraints of relative pose measurements. Since the magnetic field in indoor environments is stable in the temporal domain and sufficiently varying in the spatial domain, we can exploit these characteristics to generate the constraints of the pose graph. In this paper we provide a method of solving a simultaneous localization and mapping (SLAM) problem by employing pose graph optimization and indoor magnetic measurements. Specifically, different types of constraints for local heading correction and global loop closing, respectively, are designed. For the loop closing constraints in particular, we first examine spatial similarity of the indoor magnetic field and verify that the use of measurement sequences rather than a single measurement mitigates the ambiguity of the magnetic measurements. A loop closing algorithm is then proposed based on the sequence of magnetic measurement and applied to the pose graph optimization. Experimental results show that the proposed SLAM system with only wheel encoders and a single magnetometer obtains comparable results with a reference-level SLAM system in terms of robot trajectory, thereby validating the feasibility of applying magnetic constraints to indoor pose graph SLAM.