美文网首页
Laravel-GeoHash LBS地理位置距离计算方法geo

Laravel-GeoHash LBS地理位置距离计算方法geo

作者: YouthAge | 来源:发表于2018-06-26 14:15 被阅读0次

Laravel GeoHash

Laravel GeoHash LBS地理位置距离计算方法geohash,将一个经纬度信息,转换成一个可以排序,可以比较的字符串编码,用于高效搜索

安装方法

composer require youthage/laravel-geohash

配置方法

app.php 配置如下:

providers中添加

Geohash\GeoHashProvider::class,

aliases中添加

'GeoHash' => \Geohash\GeoHashFacade::class,

使用方法

<?php

namespace App\Http\Controllers;

use GeoHash;
class IndexController extends Controller
{
    public function index()
    {
        // 参数:纬度,经度
        $geo = GeoHash::encode("69.3252", "136.2345");
        echo $geo;

        list($lat, $lng) = GeoHash::decode($geo);
        echo $lat, ', ', $lng;
    }
}

相关文章

网友评论

      本文标题:Laravel-GeoHash LBS地理位置距离计算方法geo

      本文链接:https://www.haomeiwen.com/subject/qdtmyftx.html