-
-
- define('EARTH_RADIUS', 6370.6935);
-
- function vicinity($lng, $lat, $distance = 0.5) {
- //$distance = 0.5; // 单位 10KM
- $radius = EARTH_RADIUS;
-
- $dlng = rad2deg(2*asin(sin($distance/(2*$radius))/cos($lat)));
- $dlat = rad2deg($distance*10/$radius);
-
- $lng_left = round($lng - $dlng, 6);
- $lng_right = round($lng + $dlng, 6);
- $lat_top = round($lat + $dlat, 6);
- $lat_bottom = round($lat - $dlat, 6);
-
- return array('lng'=> array('left'=> $lng_left, 'right'=> $lng_right), 'lat'=> array('top'=> $lat_top, 'bottom'=> $lat_bottom));
- }
-
-
复制代码
|