PHP code example of k1ttyf / geospy-php

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

    

k1ttyf / geospy-php example snippets




$image = __DIR__ . "/image.jpeg";
I_KEY");

try {
    $result = $GeoSpy->predict($image);
    foreach($result["geo_predictions"] as $value){
        echo "Latitude: " . $value["coordinates"][0] . PHP_EOL;
        echo "Longitude: " . $value["coordinates"][1] . PHP_EOL;
        foreach($GeoSpy->getLocationLinks($value["coordinates"][0], $value["coordinates"][1]) as $service => $link){
            echo ucfirst($service) . ": " . $link . PHP_EOL;
        }
        echo "Score: " . $value["score"] . PHP_EOL;
        echo "Similarity Score (1km): " . $value["similarity_score_1km"] . PHP_EOL;
        echo "Address: " . $value["address"] . PHP_EOL;
        echo PHP_EOL;
    }
} catch(Exception $e){
    echo "Error: " . $e->getMessage() . PHP_EOL;
}



$latitude = 48.858112335205;
$longitude = 2.2949459552765;

>getLocationLinks($latitude, $longitude) as $service => $link){
    echo ucfirst($service) . ": " . $link . PHP_EOL;
}
shell
composer