benmanu / silverstripe-leafletfield
该软件包最新版本(2.0.1)没有可用的许可信息。
提供了一种表单字段类型,允许用户在地图上绘制功能,这些功能以单个数据库字段中的geoJSON对象的形式存储。
2.0.1
2022-11-21 02:56 UTC
Requires
- silverstripe/cms: ^4.0
- silverstripe/vendor-plugin: ^1.0
README
提供了一种表单字段类型,允许用户在地图上绘制功能,这些功能以单个数据库字段中的geoJSON对象的形式存储。
安装
$ composer require benmanu/silverstripe-leafletfield
基本用法
导入字段
use BenManu\LeafletField\LeafletField;
创建一个文本数据库字段来存储geojson值。
public static $db = array(
'Geometry' => 'Text',
);
创建一个LeafletField,传递你要存储值的对象。
$field = new LeafletField('Geometry', 'Geometry', $this);
字段选项
通过配置定义默认字段选项。
BenManu\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(array(
'center' => array(
'latitude' => '-40.866119',
'longitude' => '174.143780'
),
'zoom' => 5
));
$field->setDrawOptions(array(
'polyline' => array(
'shapeOptions' => array(
'color' => '#269634'
)
),
'polygon' => array(
'allowIntersection' => false,
'drawError' => array(
'color' => '#b00b00',
'timeout' => 1000
)
),
'rectangle' => false,
'circle' => false
));
使用与Leaflet.draw选项相同的结构设置绘制选项。
维护者联系方式
- Ben Manu ben@silverstripe.com
要求
- SilverStripe 4.0