2017-01-18 17:30:58 +01:00
|
|
|
Leaflet geocode widget
|
|
|
|
|
======================
|
|
|
|
|
|
2022-11-29 11:10:48 +01:00
|
|
|
[](https://github.com/netzmacht/contao-leaflet-geocode-widget/actions)
|
2017-10-04 11:06:58 +02:00
|
|
|
[](http://packagist.org/packages/netzmacht/contao-leaflet-geocode-widget)
|
|
|
|
|
[](http://packagist.org/packages/netzmacht/contao-leaflet-geocode-widget)
|
|
|
|
|
[](http://packagist.org/packages/netzmacht/contao-leaflet-geocode-widget)
|
|
|
|
|
|
2022-11-29 11:10:48 +01:00
|
|
|
This extension provides a widget to pick coordinates from a map. It uses the leaflet framework.
|
2017-01-18 17:30:58 +01:00
|
|
|
|
2017-10-04 11:10:03 +02:00
|
|
|
Changlog
|
|
|
|
|
--------
|
|
|
|
|
|
|
|
|
|
See [CHANGELOG](CHANGELOG.md).
|
2017-01-18 17:30:58 +01:00
|
|
|
|
|
|
|
|
Requirements
|
|
|
|
|
------------
|
|
|
|
|
|
2022-11-29 11:10:48 +01:00
|
|
|
- Contao ^4.13||^5.0
|
|
|
|
|
- PHP ^7.4||^8.0
|
2017-01-18 17:30:58 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
Install
|
|
|
|
|
-------
|
|
|
|
|
|
|
|
|
|
### 1. Install using composer
|
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
php composer.phar require netzmacht/contao-leaflet-geocode-widget
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### 2. Update your AppKernel.php
|
2017-01-26 17:11:05 +01:00
|
|
|
git
|
2017-01-26 16:56:43 +01:00
|
|
|
If you use the managed edition of Contao you can skip this step.
|
|
|
|
|
|
2017-01-18 17:30:58 +01:00
|
|
|
```php
|
|
|
|
|
|
|
|
|
|
// Dependency is automatically installed and has to be registered
|
|
|
|
|
new Contao\CoreBundle\HttpKernel\Bundle\ContaoModuleBundle('leaflet-libs', $this->getRootDir()),
|
2022-11-29 11:10:48 +01:00
|
|
|
|
2017-01-18 17:30:58 +01:00
|
|
|
// Register the bundle
|
|
|
|
|
new Netzmacht\Contao\Leaflet\GeocodeWidget\LeafletGeocodeWidgetBundle(),
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### 3. Update the assets
|
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
bin/console assets:install --symlink
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
### 4. Use the widget
|
|
|
|
|
|
2018-02-08 21:57:20 +01:00
|
|
|
#### Coordinates only
|
|
|
|
|
|
2017-01-18 17:30:58 +01:00
|
|
|
```php
|
|
|
|
|
$GLOBALS['TL_DCA']['tl_example']['fields']['coordinates'] = [
|
|
|
|
|
'label' => ['Koordinaten', 'Geben Sie die Koordinaten ein'],
|
|
|
|
|
'inputType' => 'leaflet_geocode',
|
|
|
|
|
'eval' => [
|
2017-10-04 11:10:03 +02:00
|
|
|
'tl_class' => 'w50',
|
2017-01-18 17:30:58 +01:00
|
|
|
],
|
|
|
|
|
'sql' => 'varchar(255) NOT NULL default \'\''
|
|
|
|
|
];
|
|
|
|
|
```
|
2018-02-08 21:57:20 +01:00
|
|
|
|
|
|
|
|
#### Coordinates and radius
|
|
|
|
|
|
|
|
|
|
To pick the radius in meters as well, you have to configure the `eval.radius` option for the related radius field.
|
2022-11-29 11:10:48 +01:00
|
|
|
The radius field should be a simle text input. The `default`, `minval` and `maxval` flags are passed to the geocode
|
2018-02-08 21:57:20 +01:00
|
|
|
widget so that only radius in that boundary can be chosen.
|
|
|
|
|
|
|
|
|
|
```php
|
|
|
|
|
$GLOBALS['TL_DCA']['tl_page']['fields']['coordinates'] = [
|
|
|
|
|
'label' => ['Koordinaten', 'Geben Sie die Koordinaten ein'],
|
|
|
|
|
'inputType' => 'leaflet_geocode',
|
|
|
|
|
'eval' => [
|
|
|
|
|
'tl_class' => 'w50',
|
|
|
|
|
'radius' => 'radius'
|
|
|
|
|
],
|
|
|
|
|
'sql' => 'varchar(255) NOT NULL default \'\''
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
$GLOBALS['TL_DCA']['tl_page']['fields']['radius'] = [
|
|
|
|
|
'label' => ['Radius', 'Angabe des Radius in Metern'],
|
2018-02-23 11:09:40 +01:00
|
|
|
'inputType' => 'leaflet_radius', // Optional, you can use a text widget as well
|
2022-11-29 11:10:48 +01:00
|
|
|
'eval' => [
|
2018-02-08 21:57:20 +01:00
|
|
|
'default' => 500,
|
|
|
|
|
'minval' => 100,
|
|
|
|
|
'maxval' => 5000,
|
2018-02-23 11:09:40 +01:00
|
|
|
'steps' => 100, // Round value to the closest 100m.
|
2018-02-08 21:57:20 +01:00
|
|
|
'tl_class' => 'w50',
|
|
|
|
|
],
|
|
|
|
|
'sql' => 'varchar(255) NOT NULL default \'\''
|
|
|
|
|
];
|
|
|
|
|
```
|
2018-02-08 22:23:42 +01:00
|
|
|
|
2018-02-23 11:09:40 +01:00
|
|
|
If you want to add an wizard icon to the radius field as well, you only have to reference the coordinates field.
|
2018-02-08 22:23:42 +01:00
|
|
|
|
|
|
|
|
```php
|
|
|
|
|
$GLOBALS['TL_DCA']['tl_page']['fields']['radius'] = [
|
|
|
|
|
'label' => ['Radius', 'Angabe des Radius in Metern'],
|
2018-02-23 11:09:40 +01:00
|
|
|
'inputType' => 'leaflet_radius',
|
2018-02-08 22:23:42 +01:00
|
|
|
'eval' => [
|
|
|
|
|
'rgxp' => 'natural',
|
|
|
|
|
'default' => 500,
|
|
|
|
|
'minval' => 100,
|
|
|
|
|
'maxval' => 5000,
|
|
|
|
|
'tl_class' => 'w50 wizard',
|
|
|
|
|
'coordinates' => 'coordinates'
|
|
|
|
|
],
|
|
|
|
|
'sql' => 'varchar(255) NOT NULL default \'\''
|
|
|
|
|
];
|
|
|
|
|
```
|