小编smi*_*ita的帖子

有没有办法在laravel中找到半径内的位置

如何根据一点经纬度和给定半径找到基于无线电的位置。假设,我给出了 30 作为半径,而不是在 30 半径内找到特定给定纬度和经度的结果。我试过下面的代码:

    $lat = '37.421998'; // latitude of centre of bounding circle in degrees
    $lon = '-122.084000'; // longitude of centre of bounding circle in degrees
    $rad = 30; // radius of bounding circle in kilometers

    $R = 6371;  // earth's mean radius, km

    // first-cut bounding box (in degrees)
    $maxLat = $lat + rad2deg($rad/$R);
    $minLat = $lat - rad2deg($rad/$R);
    $maxLon = $lon + rad2deg(asin($rad/$R) / cos(deg2rad($lat)));
    $minLon = $lon - rad2deg(asin($rad/$R) / cos(deg2rad($lat)));

   $results = DB::select('Select …
Run Code Online (Sandbox Code Playgroud)

php geolocation laravel-5

1
推荐指数
1
解决办法
6438
查看次数

标签 统计

geolocation ×1

laravel-5 ×1

php ×1