搜索插件、代码仓与 APP 分类

flutter_map_line_editor 封面
插件详情v8.0.0

flutter_map_line_editor

`flutter_map` 的基本线条和多边形编辑器,使用拖动标记

AndroidiOSWebmacOSWindowsLinux
近 30 天下载
6040
喜欢数
32
Pub 分数
130

安装插件

flutter pub add flutter_map_line_editor

插件介绍

基于插件公开信息、社区数据与项目使用情况整理的选型参考。

一个 Flutter 包,可在 flutter_map 小部件内实现对线条和多边形的交互式编辑。它提供可拖动的标记以调整顶点,使用户能够直接在地图上创建或修改矢量形状。专为需要用户在地图几何图形上输入的地理定位应用设计,可与 flutter_map 的现有功能无缝集成。该编辑器支持线段和多边形形状,通过触摸或鼠标操作在所有支持的平台上提供直观的点操作。

适合场景

  • 基于地图的形状创建
  • 交互式路线规划
  • 地理空间数据标注
  • 多边形边界编辑
  • 实时地图绘制
  • 用户驱动的地图几何输入

主要特点

  • 可拖动的顶点标记
  • 对线条和多边形的支持
  • 与 flutter_map 的无缝集成
  • 跨平台兼容性
  • 实时形状更新
  • 初始化和事件处理的简单 API

适合对象

  • GIS 应用
  • 带用户输入的映射工具
  • 交互式地图仪表板
  • 字段数据采集应用
  • 教育地图软件
  • 原型化地图交互功能

使用建议

  • 需要 flutter_map 依赖
  • 仅限基本形状编辑
  • 无内置的对齐或吸附功能
  • 可能需要为标记自定义样式
  • 大量顶点带来的性能影响
  • 不适合复杂的几何运算

原始 README

以下为关联源码仓库的 README 原文快照,最新内容请访问源码仓库。

Line & Polygon Editor for flutter_map

pub package License: MIT Support me on Ko-fi

A basic line and polygon editor that works with flutter_map, relying on DragMarker from flutter_map_dragmarker.

Demo

Demo

Getting started

To use this package, first add flutter_map_line_editor as a dependency in your pubspec.yaml file:

dependencies:
  flutter_map_line_editor: <latest version>

See the example directory for a complete example app demonstrating the usage of this package, here are the most important features:

  • Tap the map to add a marker, add as many as you want.
  • Drag the main points to move them.
  • Drag the intermediate points to create a new point there and drag to where you want.
  • Long press to delete a point.

Usage

Once the package is installed, make sure to import the package in the file that you are going to need it, you may also need to import flutter_map_dragmarker:

import 'package:flutter_map_dragmarker/flutter_map_dragmarker.dart';
import 'package:flutter_map_line_editor/flutter_map_line_editor.dart';

Set up a new editor instance, tipically inside initState():

var polyEditor = PolyEditor(
  points: testPolyline.points,
  pointIcon: Icon(Icons.crop_square, size: 23),
  intermediateIcon: Icon(Icons.lens, size: 15, color: Colors.grey),
  callbackRefresh: () => { this.setState(() {})},
  addClosePathMarker: false, // set to true if polygon
);

The PolyEditor takes a list of LatLng points that are used to put DragMarker's over these locations. PolyEditor does not care if the given list of points is a polyline, it could be something else. This list will be edited in place so that when the build method is triggered it will use updated points.

You must also pass a Widget (tipically an Icon) using the pointIcon parameter that will be used to represent each DragMarker.

You may also pass the optional parameter intermediateIconto display another DragMarker halfway between the main points. Dragging this marker will create another main point and the line will be split.

The screen needs to be updated during a drag, so callbackRefresh takes a function that will get called each drag frame.

For polygons or “closed paths” set the parameter addClosePathMarker to true so that the end auto-returns to the start. Otherwise, if you just want a basic polyline, set this to false.

You can add a point programmatically using the onTap callback in MapOptions:

onTap: (ll) {
  polyEditor.add(testPolyline.points, ll);
},

Add the correspondent layers as FlutterMap childrens:

FlutterMap(
  options: MapOptions(
    onTap: (_, ll) {
      polyEditor.add(testPolyline.points, ll);
    },
  ),
  children: [
    // .....
    PolylineLayer(polylines: polyLines),
    DragMarkers(markers: polyEditor.edit()),
  ],
),

Report issues or feature requests in the GitHub repository, Pull Requests are welcome!

License

This package is licensed under the permissive MIT License. See the LICENSE file in this repository to get a full copy.

所属分类

依赖

依赖清单 2 项

源码仓库

使用此插件的项目