PHP code example of b13 / geocoding

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

    

b13 / geocoding example snippets



namespace MyVendor\MyExtension\Task;

/**
 * Class to be called by the scheduler to
 * find geocoding coordinates for all tt_address records
 */
class GeocodingTask extends \TYPO3\CMS\Scheduler\Task\AbstractTask
{
    /**
     * Function executed from the Scheduler.
     */
    public function execute()
    {
        /** @var \B13\Geocoding\Service\GeoService $geocodingService */
        $geocodingService = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\B13\Geocoding\Service\GeoService::class);
        $geocodingService->calculateCoordinatesForAllRecordsInTable(
            'tt_address',
            'latitude',
            'longitude',
            'address',
            'zip',
            'city',
            'country'
        );
        return true;
    }
}

$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['scheduler']['tasks'][\MyVendor\MyExtension\Task\GeocodingTask::class] = [
    'extension'        => 'myextension',
    'title'            => 'Geocoding of address records',
    'description'      => 'Check all tt_address records for geocoding information and write them into the fields'
];