PHP code example of ujamii / ujamii-geocoder

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

    

ujamii / ujamii-geocoder example snippets


..['ctrl']['geocoder'] = [
	'triggerFields' => ['street', 'zip', 'city'],
	'getAddressString' => 'Your\Namespace\Domain\Model\YourEntity->getAddressString'
];

public function getAddressString($dataArray) {
	return $dataArray['location'];
}

$GLOBALS['TCA']['tx_news_domain_model_news']['ctrl']['geocoder'] = [
	'triggerFields' => ['street', 'zip', 'city'],
	'getAddressString' => 'Your\Namespace\Domain\Model\YourEntity->getAddressString',
	'providerParams' => [
        0 => null,
        1 => null,
        2 => '<GMAPS_API_KEY>'
    ]
];

public function getAddressString($dataArray) {
	return sprintf('%s, %s %s', $dataArray['street'], $dataArray['zip'], $dataArray['city']);
}

vendor/bin/typo3 geocoder:fillmissingdata