PHP根据gps坐标搜索附近

2015-04-23 0 629
PHP根据gps坐标搜索附近
 
<?php
  
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));
}
 

遇见资源网 php PHP根据gps坐标搜索附近 http://www.ox520.com/7580.html

常见问题

相关文章

发表评论
暂无评论
官方客服团队

为您解决烦忧 - 24小时在线 专业服务