PHP code example of leitom / geo

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

    

leitom / geo example snippets


$user->geoUnit // km
$user->geoDistance; // 0.999
 php
$users = User::geoSearch(-115.17258, 36.11996, 10)->get();
 php
[
    'geo_unit' => 'km',
    'geo_distance' => 0.999,
]
 php
$locations = Leitom\Geo\Facades\Geo::index('cars')->search(-115.17258, 36.11996, 10);
 php
$locationA = new Leitom\Geo\Coordinate('my-car', -115.17087, 36.12306);
$locationB = new Leitom\Geo\Coordinate('robins-car', -115.171971, 36.120609);

Leitom\Geo\Facades\Geo::index('cars')->between($locationA, $locationB); // 0.2900
 php
$locationA = new Leitom\Geo\Coordinate('my-car', -115.17087, 36.12306);
$locationB = new Leitom\Geo\Coordinate('robins-car', -115.171971, 36.120609);

Leitom\Geo\Facades\Geo::index('cars')->add($locationA, $locationB);

Leitom\Geo\Facades\Geo::index('cars')->add([$locationA, $locationB]);