//经纬度算法 $pi80 = M_PI / 180; $lat1=34.7465763; $lng1=113.65778739999996; $lat2=34.684795; $lng2=112.43594499999995; $lat1 *= $pi80; $lng1 *= $pi80; $lat2 *= $pi80; $lng2 *= $pi80; $r = 6372.797; // mean radius of Earth in km $dlat = $lat2 - $lat1; $dlng = $lng2 - $lng1; $a = sin($dlat/2)*sin($dlat/2)+cos($lat1)*cos($lat2)*sin($dlng/2)*sin($dlng/2); $c = 2 * atan2(sqrt($a), sqrt(1 - $a)); $km =round( $r * $c,2); // return ($miles ? ($km * 0.621371192) : $km); dump($km.‘km‘);