Geocoding Bundle for the Contao Open Source CMS
With this bundle you can easily calculate the geo position from a given address, city, place or country over the Google Geocode API with Contao 4.4.*, (*1)
A Google API key is required. You can generate a API key under the following link: https://developers.google.com/maps/documentation/geocoding/get-api-key, (*2)
Attention
This bundle is currently under development. You can use it at your own risk! A stable version will be available soon. Of course you can submit issues and feature requests on the repository issue section. Thx!, (*3)
How to install
Contao Standard Edition
Run in your project folder the following Composer command to add the Geocoding Bundle to your project:, (*4)
./composer require wr/geocoding-bundle
Add the Bundle to app/AppKernel.php
bundles array after all the Contao bundles:, (*5)
public function registerBundles()
{
$bundles = [
.....
new Wr\GeocodingBundle\WrGeocodingBundle() //Add this line.
];
....
return $bundles;
}
Clear the cache and warmup the cache with the following two commands:, (*6)
./bin/console cache:clear --no-warmup --env=prod
./bin/console cache:warmup --env=prod
Go to the install tool and update the database. Then login into the back end., (*7)
Contao Managed Edition
Without the awesome Contao Manager, (*8)
Run in your project folder the following Composer command to add the geocoding Bundle to your project:, (*9)
composer require wr/geocoding-bundle
Clear the cache and warmup the cache with the following two commands:, (*10)
vendor/bin/contao-console cache:clear --no-warmup
vendor/bin/contao-console cache:warmup
Go to the install tool and update the database. Then login into the back end., (*11)
With the awesome Contao Manager, (*12)
- Search in the Contao Manager search bar the bundle
wr/geocoding-bundle
and click on the install button.
- Go to the install tool and update the database. Then login into the back end.
Dependencies
php: ^7.0
symfony/symfony: ^3.3
contao/core-bundle: ^4.4
Usage
You can use the class with the container as follow:, (*13)
$container=\Contao\System::getContainer();
$Geocoder=container->get('wr.geocoding.geocoder');
$Geocoder->calculate($address,$country,$apiKey);
If the request was successful the geocoder object return the response object from the Google API otherwise it will return NULL., (*14)
Alternatively you can access the following properties., (*15)
$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
Licence
The geocoding bundle is published under the LGPLv3., (*16)
Documentation
Unfortunately, at the moment there is no documentation available. But we will fix this as soon as there is a stable version., (*17)
## Contact/Support, (*18)
For further information feel free and get in contact with us: mail@webrealisierung.ch, (*19)
## Donation, (*20)
If you like our work feel free to donate., (*21)
There are many ways to donate to the project. The following list contains some possibilities:, (*22)
- Contribute your code over pull requests.
- Test, test, test and feedback.
- Submit features or issues.
- Tell us a joke.
-
You know that every coffee counts while coding:-)