php sql 腾讯地图根据两点经纬度计算距离

//距离计算
$sqrt = 'SQRT(POW(SIN(('.$latitude.'*PI()/180-`latitude`*PI()/180)/2),2)+COS('.$latitude.'*PI()/180)*COS(`latitude`*PI()/180)*POW(SIN(('.$longitude.'*PI()/180-`longitude`*PI()/180)/2),2))';
 //表前缀
 $prefix = config('database.prefix');
 //条件
 $where =  "'%".$key."%'" ;
 //sql语句
 $sql = "select * from (select * ,ROUND(6378.138*2*ASIN($sqrt)*1000) AS distance from  " .$prefix ."store". "  where store_name like ".  $where ." or address like ".  $where ."  order by distance,id) as a ";
    Db::query($sql);
上一篇:Javascript学习总结 - html5实现定位地理位置


下一篇:mysql 查询附近N公里内数据