PHP code example of ligorikus / h3-php

1. Go to this page and download the library: Download ligorikus/h3-php 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/ */

    

ligorikus / h3-php example snippets




use H3\H3;
use H3\ValueObject\LatLng;

$latLng = new LatLng(37.7749, -122.4194);
$resolution = 9;

$cell = H3::latLngToCell($latLng, $resolution);

echo dechex($cell) . "\n"; // 89283082803ffff

$center = H3::cellToLatLng($cell);

printf("Latitude: %.6f, Longitude: %.6f\n", $center->lat, $center->lng);
// Latitude: 37.773515, Longitude: -122.418271
bash
composer