根据经纬度获取地理位置

  public function  car_source_location($lng,$lat,$log){

$sql = "select a.*, ROUND(6378.138*2*ASIN(SQRT(
POW(SIN(({$lat}*PI()/180-lat*PI()/180)/2),2)
+COS({$lat}*PI()/180)
*COS(lat*PI()/180)
*POW(SIN(({$lng}*PI()/180-lng*PI()/180)/2),2)
))*1000) AS distance
FROM `tp_group` a

HAVING distance <= {$log}";

// Log::record("car_source_location: ".$sql)." -- ".time();
$group= M("group");
$location = $group->query($sql);

return $location;
}
posted @ 2020-12-14 16:38  php毛宏历的博客  阅读(676)  评论(0编辑  收藏  举报