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

插件详情v8.0.3

flutter_map_dragmarker

flutter_map 的 Dragmarker 类

AndroidiOSWebmacOSWindowsLinux
近 30 天下载
2.9万
喜欢数
33
Pub 分数
130

安装插件

flutter pub add flutter_map_dragmarker

插件介绍

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

一个用于 flutter_map 的拖拽标记小部件,允许用户在地图上交互式地放置和移动标记。它扩展了 flutter_map 的功能,使用户能够将标记拖动到所需位置,非常适合需要精确地理定位输入的应用程序。该包与 flutter_map 现有的 API 无缝集成,并支持所有主要平台,包括移动设备、网页和桌面端。它轻量且设计简洁,同时不牺牲核心功能。

适合场景

  • 交互式地图标记放置
  • 地理位置数据录入
  • 基于地图的表单输入
  • 实时位置调整
  • 可自定义的标记拖动行为

主要特点

  • 可拖动标记支持
  • 与 flutter_map 的无缝集成
  • 跨平台兼容性
  • 可自定义的拖动行为
  • 轻量且易于实现

适合对象

  • 开发交互式地图的开发者
  • 需要用户定义坐标的应用程序
  • 位置感知表单
  • 地图编辑工具
  • 原型化地理空间功能

使用建议

  • 需要安装 flutter_map
  • 仅限标记特定的交互
  • 位置无内置验证
  • 可能需要额外的样式设置以实现自定义视觉效果
  • 不适合复杂的多标记操作

原始 README

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

flutter_map_dragmarker

A drag marker for flutter_map.

See the example/lib/main.dart for usage, but the included example below in this file should show pretty much everything.

ko-fi

Usage

  • This layer should probably be the last layer so IF it needs to be dragged (otherwise why would you use this :)). If not, other layers may intercept the gestures.
  • offset and dragOffset are there for tweaking icon/images if they should not get displayed centered.
  • height is mainly for Images, use Icon(..., size: ...), but be aware internal calculations are based on size.
  • rotateMarker toggles the markers' rotation on and off. True keeping markers upright.
  • Use scrollMapNearEdge if the map should scroll when a marker is dragged near the edge.
  • Enable useLongPress if you want to enable dragging after a long press
  FlutterMap(
    options: MapOptions(center: LatLng(45.5231, -122.6765), zoom: 9),
    children: [
      TileLayer(
        urlTemplate: 'https://tile.openstreetmap.org/{z}/{x}/{y}.png',
      ),
      DragMarkers(
        markers: [
          DragMarker(
            point: LatLng(45.535, -122.675),
            offset: const Offset(0.0, -8.0),
            builder: (ctx) => const Icon(Icons.location_on, size: 50),
            onDragUpdate: (details, latLng) => print(latLng),
          ),
        ],
      ),
    ],
  ),

Further notes

It may be interesting to move the map alternately to marker, too. So the marker stays in place, but then technically you aren't dragging anymore, so thoughts welcome.

所属分类

依赖

依赖清单 2 项

源码仓库

使用此插件的项目