/** * 计算经纬度距离 * @param $d */ public function rad($d) { return $d * 3.1415926535898 / 180.0; } public function getDistance($lat1, $lng1, $lat2, $lng2) { $EARTH_RADIUS = 6378.137; $radLat1 = $this->rad($lat1); //echo $radLat1; $radLat2 = $this->rad($lat2); $a = $radLat1 - $radLat2; $b = $this->rad($lng1) - $this->rad($lng2); $s = 2 * asin(sqrt(pow(sin($a/2),2) + cos($radLat1)*cos($radLat2)*pow(sin($b/2),2))); $s = $s *$EARTH_RADIUS; $s = round($s * 10000) / 10000; return $s; } /** * 计算经纬度距离 * @param $d */ 你的当前访问异常,请进行认证后继续阅读剩余内容。 提交