In the CERN experiment NA62, low-mass straw-tube tracking-chambers have been designed to operate in vacuum and, in conjunction with precisely mapped magnetic fields, enable the determination of the trajectories of the charged decay products of a 75 GeV/c K+ with high accuracy. This is particularly important for the crucial measurement of the branching fraction for the decay K+ → π+ ν ν, which has the potential to reveal BSM physics. The charged particles passing through the magnetic field of a dipole magnet receive a transverse-momentum kick, ΔPT = 270 MeV/c, which the physics requires to be determined to better than one part in a thousand. This puts stringent constraints on the required accuracy and precision of the magnetic field components at all points through which charged particles pass. Before reaching the dipole magnet the particles travel through an evacuated steel tank of length 90 m, where residual magnetic fields of typical size 50 μT modify the trajectories of the charged particles and require measurement with a precision of better than 10 μT. In this paper we describe in detail the different approaches to the measurement and analysis of the magnetic field for the two regions, the corrections to the raw data necessary to produce the final field map, and the physics validation procedures showing that the required accuracy and precision of the field maps have been achieved.