地图上半径内的经纬度
/* * 地图上半径内的经纬度 * @param lat 纬度 lon 经度 raidus 单位米 */ function getAround($lat,$lon,$raidus){ $raidus = empty($raidus)?3000:$raidus; $PI = 3.14159265; $latitude = $lat; $longitude = $lon; $degree = (24901*1609)/360.0; $raidusMile = $raidus; $dpmLat = 1/$degree; $radiusLat = $dpmLat*$raidusMile; $minLat = $latitude-$radiusLat; $maxLat = $latitude + $radiusLat; $mpdLng = $degree*cos($latitude * ($PI/180)); $dpmLng = 1 / $mpdLng; $radiusLng = $dpmLng*$raidusMile; $minLng = $longitude - $radiusLng; $maxLng = $longitude + $radiusLng; $data['minLat'] = $minLat; $data['maxLat'] = $maxLat; $data['minLng'] = $minLng; $data['maxLng'] = $maxLng; return $data; }
根据距离远近来排序,大概思路,没去写,到时候用到再改 order by ( |Latitude-当前纬度|+|Longitude-当前经度|) asc