Generally, a magnetic target includes ferromagnetic material, which can be generated the magnetic anomaly. Based on the magnetic anomaly, we can use a sensor array to locate a magnetic target. Due to sensors located on a vehicle, the distortion field generated by it can affect the value measured by the magnetic sensor. Therefore, the distortion field needs to be compensated. In this paper, the sensor array with four magnetometers and an inertial instrument is presented. We analyze the relationship between the measurements of each magnetometers in the array. Then, we propose a method for compensating the distortion field generated by the vehicle. In addition, we present a method for locating the magnetic target using the sensor array. Based on the magnetic moment, we formulate an optimization problem for estimating the parameters of the target and develop a dedicated PSO algorithm to solve the optimization. From the experiment results, we can know that the calculated positions of the target by the method were near the true values.