PHP code example of puwnz / google-maps-lib

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

    

puwnz / google-maps-lib example snippets




use Puwnz\GoogleMapsLib\Constants\SupportedLanguage;
use Puwnz\GoogleMapsLib\Constants\SupportedRegion;
use Puwnz\GoogleMapsLib\Geocode\QueryBuilder\GeocodeQueryBuilder;
use Puwnz\GoogleMapsLib\Geocode\Type\GeocodeComponentQueryType;
use Puwnz\GoogleMapsLib\GoogleServiceFactory;
use Symfony\Component\Validator\Validation;

$geocode = GoogleServiceFactory::create('google-api-key', 'path/log/file', 'http-version');

$components = [
    GeocodeComponentQueryType::COUNTRY => 'FR'
];

$geocodeQueryBuilder = new GeocodeQueryBuilder(Validation::createValidator());

$geocodeQueryBuilder->setAddress('10 rue de la Paix, Paris')
    ->setComponents($components)
    ->setLanguage(SupportedLanguage::FRENCH)
    ->setRegion(SupportedRegion::FR)
    ->setBounds([
        'northeast' => [
            'lat' => 0.0,
            'lng' => 1.0
        ],
        'southwest' => [
            'lat' => -0.0,
            'lng' => -1.0
        ]
    ]);

$response = $geocode->apply($geocodeQueryBuilder);