//地球半径 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-$dlat), 'right-top'=>array('lat'=>$lat+$dlat,'lng'=>$lng+$dlat), 'left-bottom'=>array('lat'=>$lat-$dlat,'lng'=>$lng-$dlat), 'right-bottom'=>array('lat'=>$lat-$dlat,'lng'=>$lng+$dlat) ); 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