PHP code example of navjobs / google-geocoder

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

    

navjobs / google-geocoder example snippets


// config/app.php
'providers' => [
    // other providers
    'ConstructionJobs\GoogleGeocoder\GoogleGeocoderServiceProvider'
];

php artisan vendor:publish --provider="ConstructionJobs\GoogleGeocoder\GoogleGeocoderServiceProvider"

// Geocode an address
$geocoder = new Geocoder;
$geocoder->geocode('New York, NY');

// Reverse geocode from coordinates
$geocoder = new Geocoder;
$geocoder->reverseByCoordinates(40.7127837, -74.0059413);

// Reverse geocode from a Google place id.
$geocoder = new Geocoder;
$geocoder->reverseByPlaceId('ChIJOwg_06VPwokRYv534QaPC8g');

[
    'address' => 'New York, NY, USA',
    'latitude' => 40.7127837,
    'longitude' => -74.0059413,
    'place_id' => ChIJOwg_06VPwokRYv534QaPC8g,
    'types' => [
        'locality',
        'political'
    ]
    $bounds = [
        'northeast' => [
            'latitude' => 40.9152555,
            'longitude' => -73.7002721,
        ],
        'southwest' => [
            'latitude' => 40.496044,
            'longitude' => -74.255735,
        ]
    ];
}