nzta/googlemap-leafletfield

提供了一种表单字段类型,允许用户在地图上绘制要素,这些要素以单个数据库字段中的geoJSON对象的形式存储

安装: 329

依赖项: 0

建议者: 0

安全: 0

星星: 0

观察者: 4

分支: 8

语言:JavaScript

类型:silverstripe-vendormodule

2.0.0 2018-10-25 22:31 UTC

This package is auto-updated.

Last update: 2024-09-12 13:22:13 UTC


README

提供了一种表单字段类型,允许用户在地图上绘制要素,这些要素以单个数据库字段中的geoJSON对象的形式存储。

安装

$ composer require NZTA/googlemap-leafletfield

基本用法

导入字段

use NZTA\LeafletField\LeafletField;

创建一个文本数据库字段以存储geojson值。

public static $db = [
    'Geometry' => 'Text',
];

创建一个LeafletField,传递你想要存储值的对象。

$field = new LeafletField('Geometry', 'Geometry', $this);

Leaflet.draw演示

字段选项

通过配置定义默认字段选项。

NZTA\LeafletField\LeafletField:
  map_options:
    center:
      latitude: "-40.866119"
      longitude: "174.143780"
    zoom: 5
  draw_options:
    polyline:
      shapeOptions:
        color: '#269634'
    polygon:
      allowIntersection: false
      drawError:
        color: '#b00b00'
        timeout: 1000
    rectangle: false
    circle: false

为单个字段实例定义自定义选项(覆盖默认选项)。

$field->setLimit(1); // Limit the amount of objects the field can contain.
$field->setMapOptions([
    'center' => [
        'latitude' => '-40.866119',
        'longitude' => '174.143780'
    ],
    'zoom' => 5
]);
$field->setDrawOptions([
    'polyline' => [
        'shapeOptions' => [
            'color' => '#269634'
        ]
    ],
    'polygon' => [
        'allowIntersection' => false,
        'drawError' => [
            'color' => '#b00b00',
            'timeout' => 1000
        ]
    ],
    'rectangle' => false,
    'circle' => false
]);

绘制选项使用与Leaflet.draw选项相同的结构。

要求

  • SilverStripe 4.0

项目链接