PHP code example of dotzero / gmaps-geocode

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

    

dotzero / gmaps-geocode example snippets


try {
    $result = (new GMapsGeocode('YOUR_GOOGLE_API'))
        ->setAddress('Helsinki')
//        ->setRegion('FI')
        ->setComponents(array(
            'route' => 'Annegatan',
            'administrative_area' => 'Helsinki',
            'country' => 'Finland'
        ))
        ->search();

    print_r($result);
} catch (GMapsException $e) {
    printf('Error (%d): %s', $e->getCode(), $e->getMessage());
}

try {
    $geo = (new GMapsGeocodeReverse('YOUR_GOOGLE_API'))
        ->setLatLng('40.714224', '-73.961452')
//        ->setPlaceId('ChIJd8BlQ2BZwokRAFUEcm_qrcA')
        ->search();

    print_r($result);
} catch (GMapsException $e) {
    printf('Error (%d): %s', $e->getCode(), $e->getMessage());
}

     
bash
$ git clone https://github.com/dotzero/gmaps-geocode-php/