php 計算坐標點方圓周圍多少米的坐標算法
阿新 • • 發佈:2019-04-23
() action pre 百度 public point UNC pub function
//地球半徑 6371千米 const EARTH_ROUNT = 6371; /** * @param $distance 方圓多少千米 默認500米 */ private function _getAround($lng,$lat,$distance=0.5) { $dlng = 2 * asin(sin($distance / (2*self::EARTH_ROUNT) ) / cos(deg2rad($lat)) ); $dlng = rad2deg($dlng); $dlat= $distance/self::EARTH_ROUNT; $dlat = rad2deg($dlat); $around = 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)
);var_dump($around); } public function actionCheating() { $lng = ‘121.437799‘; $lat = ‘31.243208‘; $this->_getAround($lng,$lat); }
根據坐標查詢驗證的百度地圖地址
http://api.map.baidu.com/lbsapi/getpoint/index.html
php 計算坐標點方圓周圍多少米的坐標算法