PHP code example of devpack / geo-fetcher

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

    

devpack / geo-fetcher example snippets




use DevPack\GeoFetcher\GeoFetcher;

$geoFetcher = new GeoFetcher([
    'apiKey' => 'yourApiKey',     // O 639-1
]);

// Feth coordinates from adress - parameter must be array
$result = $geoFetcher->fetchCoordinates(
    ['Kielce, Mickiewicza 1'],
);

array:1 [
    0 => array:2 [
        "lat" => 50.8676012
        "lng" => 20.6329186
    ]
]

// Fetch address from coordinates - parameter must be array
$result = $geoFetcher->fetchAddresses([
    [
        'lat' => 50.869023,
        'lng' => 20.634476,
    ],
]);

array:1 [
    0 => array:8 [
        "country" => "Polska"
        "administrative_area_level_1" => "województwo świętokrzyskie"
        "locality" => "Kielce"
        "route" => "Henryka Sienkiewicza"
        "postal_code" => "25-350"
        "street_number" => "3"
        "lat" => 50.869023
        "lng" => 20.634476
    ]
]