UAVs are widely used in agriculture, the military, and industry. However, it is easy to perform GPS spoofing attacks on UAVs, which can lead to catastrophic consequences. In this paper, we propose ConstDet, a control semantics-based detection approach for GPS spoofing attacks of UAVs using machine learning algorithms. Various real experiments are conducted to collect real flight data, on the basis of which ConstDet is designed as a practical detection framework. To train models for the detection of GPS spoofing attacks, specified flight data types are selected as features based on the control semantics, including the altitude control process and the horizontal position control process, since these data are able to represent the dynamic flight and control processes. Multiple machine learning algorithms are used to train and generate the best classifier for GPS spoofing attacks. ConstDet is further implemented and deployed on a real UAV to support onboard detection. Experiments and evaluations validate that ConstDet can effectively detect GPS spoofing attacks and the detection rate can reach 97.70%. The experimental comparison demonstrates that ConstDet has better performance than existing detection approaches.