PHP code example of hcg / get-mbr

1. Go to this page and download the library: Download hcg/get-mbr library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

hcg / get-mbr example snippets




use Hcg\GetMbr\GetMbr as GetMbr;

# 获取经纬度104.031252,30.710894,半径为10公里的'MBR'数据
# 返回数组,其中包含字段:
# MaxLatitude:最大经度
# MinLatitude:最小经度
# MaxLongitude:最大纬度
# MinLongitude:最大纬度
$gpsdis = (new Getmbr)->Main(104.031252,30.710894,10);

# 根据经纬度,计算2个点之间的距离。
# 返回距离(单位公里、千米)
$distance = (new Getmbr)->Distance(104.031252, 30.710894, 103.863918,30.447486);

# $gpsdis变量的结果
array(4) {
  ["MaxLatitude"]=>
  float(104.12115880154)
  ["MinLatitude"]=>
  float(103.94134519846)
  ["MaxLongitude"]=>
  float(30.34006953811)
  ["MinLongitude"]=>
  float(31.08171846189)
}
# $distance变量的结果
float(19.900953356431)