PHP code example of youthage / laravel-geohash

1. Go to this page and download the library: Download youthage/laravel-geohash 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/ */

    

youthage / laravel-geohash example snippets


composer 



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;
    }
}