Looking to hire Laravel developers? Try LaraJobs

laravel-geohash maintained by frankiez

Description
LBS地理位置距离计算方法geohash,将一个经纬度信息,转换成一个可以排序,可以比较的字符串编码,用于高效搜索
Author
Last update
2019/01/31 20:42 (dev-master)
License
Links
Downloads
15

Comments
comments powered by Disqus

Laravel GeoHash

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

安装方法

composer require youthage/laravel-geohash

使用方法

<?php

namespace App\Http\Controllers;

use GeoHash;
class IndexController extends Controller
{
    public function index()
    {
        // 参数:纬度,经度,长度(可选,默认为最长)
        $geo = GeoHash::encode("69.3252", "136.2345", 9);
        echo $geo;
        
        list($lat, $lng) = GeoHash::decode($geo);
        echo $lat, ', ', $lng;
    }
}