latrell/geohash

此包支持 Laravel 5 的 geohash 功能。

1.0.0 2015-03-10 10:01 UTC

This package is not auto-updated.

Last update: 2024-09-24 02:47:29 UTC


README

此包支持 Laravel 5 的 geohash 功能。

安装

composer require latrell/geohash dev-master

使用 composer update 更新包或使用 composer install 安装。

config/app.php 中找到 providers 键并注册 Geohash 服务提供者。

    'providers' => [
        // ...
        'Latrell\Geohash\GeohashServiceProvider',
    ]

config/app.php 中找到 aliases 键。

    'aliases' => [
        // ...
        'Geohash' => 'Latrell\Geohash\Facades\Geohash',
    ]

用法

编码坐标

echo Geohash::encode(31.283131, 121.500831); // wtw3uyfjqw61

解码 Geohash

list($lat, $lng) = Geohash::decode('wtw3uyfjqw61');
echo $lat, ', ', $lng; // 31.283131, 121.500831