netzmacht / contao-leaflet-geocode-widget
基于Leaflet的地理编码小部件
1.4.0
2022-11-29 12:40 UTC
Requires
- php: ^7.4 || ^8.0
- contao/core-bundle: ^4.13 || ^5.0
- netzmacht/contao-leaflet-libraries: ~1.3
- symfony/config: ^5.4 || ^6.0
- symfony/dependency-injection: ^5.4 || ^6.0
- symfony/http-kernel: ^5.4 || ^6.0
Requires (Dev)
- contao/manager-plugin: ^2.0
- doctrine/coding-standard: ^9.0
- phpcq/runner-bootstrap: 1.x-dev
- phpspec/phpspec: ^6.3.0 || ^7.0
Suggests
- netzmacht/contao-leaflet-maps: Leaflet Maps for Contao
This package is auto-updated.
Last update: 2024-09-04 16:24:32 UTC
README
此扩展提供了一种从地图中选择坐标的小部件。它使用Leaflet框架。
变更日志
查看 变更日志。
需求
- Contao ^4.13||^5.0
- PHP ^7.4||^8.0
安装
1. 使用composer安装
php composer.phar require netzmacht/contao-leaflet-geocode-widget
2. 更新您的AppKernel.php
git 如果您使用Contao的托管版,您可以跳过此步骤。
// Dependency is automatically installed and has to be registered new Contao\CoreBundle\HttpKernel\Bundle\ContaoModuleBundle('leaflet-libs', $this->getRootDir()), // Register the bundle new Netzmacht\Contao\Leaflet\GeocodeWidget\LeafletGeocodeWidgetBundle(),
3. 更新资源
bin/console assets:install --symlink
4. 使用小部件
仅坐标
$GLOBALS['TL_DCA']['tl_example']['fields']['coordinates'] = [ 'label' => ['Koordinaten', 'Geben Sie die Koordinaten ein'], 'inputType' => 'leaflet_geocode', 'eval' => [ 'tl_class' => 'w50', ], 'sql' => 'varchar(255) NOT NULL default \'\'' ];
坐标和半径
要同时选择以米为单位的半径,您必须为相关的半径字段配置 eval.radius
选项。半径字段应是一个简单的文本输入。将 default
、minval
和 maxval
标志传递给地理编码小部件,以便只能在该边界内选择半径。
$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'], 'inputType' => 'leaflet_radius', // Optional, you can use a text widget as well 'eval' => [ 'default' => 500, 'minval' => 100, 'maxval' => 5000, 'steps' => 100, // Round value to the closest 100m. 'tl_class' => 'w50', ], 'sql' => 'varchar(255) NOT NULL default \'\'' ];
如果您还想在半径字段中添加一个向导图标,您只需引用坐标字段即可。
$GLOBALS['TL_DCA']['tl_page']['fields']['radius'] = [ 'label' => ['Radius', 'Angabe des Radius in Metern'], 'inputType' => 'leaflet_radius', 'eval' => [ 'rgxp' => 'natural', 'default' => 500, 'minval' => 100, 'maxval' => 5000, 'tl_class' => 'w50 wizard', 'coordinates' => 'coordinates' ], 'sql' => 'varchar(255) NOT NULL default \'\'' ];