搜尋套件、儲存庫與 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 項

原始碼儲存庫

使用此套件的專案