查询方便已集成到 moyi 插件
$Area = new appadminmodelmoyiArea();print_r($Area::getAreaInfo('120.06851','31.71121',2));//返回参考Array ( [id] => 320400 [pid] => 320000 [name] => 常州市 [level] => 2 [code] => 0519 [postcode] => 213000 [lng] => 119.946973 [lat] => 31.772752 )
--------- 我是分割线 ---------
突发奇想用大数据搞一波事情,看看周边附近有谁发了动态
基于另外一个demo
https://ask.fastadmin.net/article/12556.html
主要代码如下
// 当前坐标系 $longitude = $this->request->post('longitude',0); $latitude = $this->request->post('latitude',0); //查询距离 米 $distance = 9999999999 ; // 查询页 $page = 0; $limit = 50; // 获取表头 $prefix = Config::get('database.prefix'); // 查询坐标系附近坐标增加一个distance字段 只要id $data = Db::query('select t.id,t.longitude,t.latitude, TRUNCATE(st_distance(point ('.$longitude.', '.$latitude.'),point(t.longitude,t.latitude)),10)* 6370.996 * 1000 as distance from '.$prefix.'moyicosmic_cosmos t HAVING distance >= 0 and distance < '.$distance.' ORDER BY distance LIMIT '.$page*$limit.','. $limit .' '); if(!$data){ $this->error('当前坐标没有数据'); } $arr = []; foreach ($data as $index => $item) { $arr[] = $item['id']; } $cosmos = new Cosmos(); $list = $cosmos->with(['user']) ->select($arr); foreach ($list as $index => $item) { $item['distance'] = ceil($data[$index]['distance'] ); } $this->success('',['list'=>$list]);
希望以上内容对你有所帮助!如果还有其他问题,请随时提问。 各类知识收集 拥有多年CMS企业建站经验,对 iCMS, Fastadmin, ClassCMS, LeCMS, PbootCMS, PHPCMS, 易优CMS, YzmCMS, 讯睿CMS, 极致CMS, Wordpress, HkCMS, YznCMS, WellCMS, ThinkCMF, 等各类cms的相互转化,程序开发,网站制作,bug修复,程序杀毒,插件定制都可以提供最佳解决方案。