PHP code example of wr / geocoding-bundle

1. Go to this page and download the library: Download wr/geocoding-bundle 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/ */

    

wr / geocoding-bundle example snippets


public function registerBundles()
    {
        $bundles = [
            .....    
            new Wr\GeocodingBundle\WrGeocodingBundle() //Add this line.
        ];

        ....
        
        return $bundles;
    }

$container=\Contao\System::getContainer();
$Geocoder=container->get('wr.geocoding.geocoder');
$Geocoder->calculate($address,$country,$apiKey);

$Geocoder->lat; //return the latitute
$Geocoder->lng; //return the longitute
$Geocoder->coords; // return the coordinate in seprated with a coma
$Geocoder->formattedAddress; // return the address formatted by the Google Geocoding API
$Geocoder->placeId; //return the Google Place ID
$Geocoder->types; //return the Google Geo Position type
$Geocoder->status; //return the Google API status
$Geocoder->geocoderResponse; //return the response object form the Google API