Download the PHP package ujamii/ujamii-geocoder without Composer
On this page you can find all versions of the php package ujamii/ujamii-geocoder. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download ujamii/ujamii-geocoder
More information about ujamii/ujamii-geocoder
Files in ujamii/ujamii-geocoder
Package ujamii-geocoder
Short Description Connecting http://geocoder-php.org/Geocoder with TYPO3 DataHandler API
License MIT
Informations about the package ujamii-geocoder
ujamii-geocoder
Connecting http://geocoder-php.org/Geocoder with TYPO3 DataHandler API. With this extension you can easily add geo data to records while they are changed by editors in the TYPO3 backend. You just have to configure how your entity "looks like" in the eyes of the geocoder via TCA anf that's it.
- Installation
- Usage
- Example
- TODOs
Installation
Currently only works in composer mode of TYPO3, so
Usage
Just add a new config array to the ctrl
section of your TCA.
And provide a method (e.g. in an entity or helper class) to generate a compound address string based on the database data of one entity (example below).
Options
Those options are possible:
triggerFields (mandatory)
Changes in those fields will trigger the process of geocoding.
getAddressString (mandatory)
A method called via TYPO3\CMS\Core\Utility\GeneralUtility::callUserFunction
which is supposed
to return a complete address string. The first parameter provided to this method is the merged
data array (unchanged entity data from db + changed values from the backend form).
Example:
locale (default: de)
The locale which is used in the geocoder.
latField (default: lat)
Name of the target field for the latitude value.
lngField (default: lng)
Name of the target field for the longitude value.
httpClientClass (default: \Http\Adapter\Guzzle6\Client::class)
Class name of the http client, see possible packages
providerClass (default: \Geocoder\Provider\GoogleMaps\GoogleMaps::class)
Class name of the provider, see possible packages
providerParams
Optional parameters for the provider. (e.g. an API key for Google Maps)
geocoderClass (default: \Geocoder\StatefulGeocoder::class)
Class name of the geocoder.
Example
Let's assume the record is a news record in the database with 3 fields: location, lat and lng. The field location
contains something like Alexanderplatz, Berlin, Deutschland
and lat and lng are the fields you want to be filled
automatically as soon as an editor changes the location.
Add this to your typo3conf/ext/your_extension/Configuration/TCA/Overrides/tx_news_domain_model_news.php
or typo3conf/ext/your_extension/Configuration/TCA/tx_ext_domain_model_entity.php
file.
In YourEntity
, add a method like this:
Usage as command or in scheduler
The extension also provides command to populate rows with 0 values for the lat/lng fields. It reads the configuration from TCA and iterates through each configured table, searching with lat = 0 OR lng = 0. For each matching row, the geocoding process is executed and the values are then updated in the database. The command produces some log output to track what has been done.
As it is a default Symfony console command, this can also be called by a scheduler task.
TODOs
- publish in TER
- right now providerParams[0] is always filled with the httpClient, which may not work for all providers
All versions of ujamii-geocoder with dependencies
geocoder-php/google-maps-provider Version ^4.2
php-http/guzzle6-adapter Version ^1.1
php-http/message Version ^1.6