netzmacht/contao-leaflet-geocode-widget

基于Leaflet的地理编码小部件

资助包维护!
dmolineus

安装量: 14,430

依赖项: 2

建议者: 0

安全性: 0

星级: 0

关注者: 2

分支: 1

开放问题: 2

类型:contao-bundle

1.4.0 2022-11-29 12:40 UTC

README

Build Status Version License Downloads

此扩展提供了一种从地图中选择坐标的小部件。它使用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 选项。半径字段应是一个简单的文本输入。将 defaultminvalmaxval 标志传递给地理编码小部件,以便只能在该边界内选择半径。

$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 \'\''
];