PHP code example of madeitbelgium / geocode-by-address

1. Go to this page and download the library: Download madeitbelgium/geocode-by-address 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/ */

    

madeitbelgium / geocode-by-address example snippets


composer 

"madeitbelgium/geocode-by-address": "^1.0"

MadeITBelgium\Geocode\ServiceProvider\Geocode::class,

'Geocode' => MadeITBelgium\Geocode\Facade\Geocode::class,

php artisan vendor:publish --provider="MadeITBelgium\Geocode\ServiceProvider\Geocode"

use MadeITBelgium\Geocode\Geocode;

$geocode = new Geocode($type = 'geocode.xyz', $apikey = null, $client = null);
$geodata = $geocode->lookup('Nieuwstraat, Brussel, Belgium');
if($geodata !== false) {
    $latitude = $geodata[0];
    $longitude = $geodata[1];
}

use MadeITBelgium\Geocode\Facade\Geocode;
$geodata = Geocode::lookup('Nieuwstraat, Brussel, Belgium');
if($geodata !== false) {
    $latitude = $geodata[0];
    $longitude = $geodata[1];
}

use MadeITBelgium\Geocode\Facade\Geocode;
$geodata = Geocode::structuredLookup('Nieuwstraat', '1', 'Brussel', '1000', 'Belgium');
if($geodata !== false) {
    $latitude = $geodata[0];
    $longitude = $geodata[1];
}