thinkphp5 根据经纬度的写法

public function returnSquarePoint($lng, $lat,$distance = 0.5)
    {
        $dlng =  2 * asin(sin($distance / (2 * 6371)) / cos(deg2rad($lat)));
        $dlng = rad2deg($dlng);
        $dlat = $distance/6371;
        $dlat = rad2deg($dlat);
        return array(
            'left-top'=>array('lat'=>$lat + $dlat,'lng'=>$lng-$dlng),
            'right-top'=>array('lat'=>$lat + $dlat, 'lng'=>$lng + $dlng),
            'left-bottom'=>array('lat'=>$lat - $dlat, 'lng'=>$lng - $dlng),
            'right-bottom'=>array('lat'=>$lat - $dlat, 'lng'=>$lng + $dlng)
        );
    }

方法

条件

$map = array("lat" => array(array('egt',$res['right-bottom']['lat']),array('elt',$res['left-top']['lat']),'or'),
             "lon" => array(array('egt',$res['left-top']['lng']),array('elt',$res['right-bottom']['lng']),'or'),
                );

你可能感兴趣的:(Thinkcmf)