搜尋套件、儲存庫與 APP 分類

flutter_map_location_marker 封面
套件詳情v10.3.0

flutter_map_location_marker

一個用於顯示設備當前位置的Flutter地圖外掛程式。

AndroidiOSWebmacOSWindowsLinux
近 30 天下載
5.2萬
喜歡數
188
Pub 分數
150

安裝套件

flutter pub add flutter_map_location_marker

套件介紹

根據套件公開資料產生的選型評估,僅供參考。

一個 Flutter 插件,可使用 flutter_map 在地圖上顯示裝置的目前位置。它提供了一種簡單的方法,透過可自訂的標記即時視覺化使用者的實時位置,進而增強基於地理定位的應用程式。此插件與 flutter_map 套件無縫整合,並支援多個平台,包括 Android、iOS、Web、macOS、Windows 與 Linux。非常適合需要位置感知功能的應用程式,例如導航工具、送貨追蹤或位置分享服務。

適用情境

  • 即時位置追蹤
  • 導航應用
  • 配送與物流
  • 基於位置的服務
  • 地圖覆蓋層與使用者位置

主要特色

  • 顯示目前裝置位置
  • 可自訂位置標記
  • 與 flutter_map 的無縫整合
  • 支援多個平台
  • 位置變更的自動更新

適合對象

  • 開發地圖整合應用的開發者
  • 需要即時GPS追蹤的應用程式
  • 跨平台地理位置解決方案
  • 位置感知儀表板

使用建議

  • 需要位置權限
  • 激活時可能耗電
  • 依賴於已安裝的 flutter_map
  • 準確性取決於設備的GPS
  • 需要對權限請求進行正確處理

原始 README

以下為關聯原始碼儲存庫的 README 原文快照,最新內容請造訪原始碼儲存庫。

flutter_map_location_marker

pub package github tag license

flutter_map_location_marker is a flutter_map plugin for displaying the device's current location on a map. It provides a simple and flexible way to add a customizable location marker to your map.
Interface preview

Join flutter_map Discord server to talk about flutter_map_location_marker, get help and help others in the #plugins channel.

Features

  • Simple: The only thing you need to do is to add a CurrentLocationLayer() to your map because all parameters have good default values.

  • Flexible: The default implementation receives the device's position from the geolocator package and the device's heading from the flutter_rotation_sensor package, but with type conversion, streams from other sources are also supported.

  • Auto-following: The map follows the new location when the location is updated. This feature is disabled by default.

  • Auto-rotating: The map can be rotated automatically in navigation mode. This feature is disabled by default.

  • Customization: The location marker can be fully customized, including the colors of the accuracy circle and heading sector.

Usage

  1. Add flutter_map_location_marker to your pubspec.yaml:

    dependencies:
      flutter_map_location_marker: any # or latest version
    
  2. Add permission by following the instructions from the geolocator package.

  3. Add the layer widget into FlutterMap:

    Widget build(BuildContext context) {
      return FlutterMap(
        children: [
          TileLayer(
            urlTemplate: 'https://tile.openstreetmap.org/{z}/{x}/{y}.png',
            maxZoom: 19,
          ),
          CurrentLocationLayer(), // <-- add layer here
        ],
      );
    }
    
  4. Discover more parameters in CurrentLocationLayer .

    Widget build() {
      return CurrentLocationLayer(
        alignPositionOnUpdate: AlignOnUpdate.always,
        alignDirectionOnUpdate: AlignOnUpdate.never,
        style: LocationMarkerStyle(
          marker: const DefaultLocationMarker(
            child: Icon(
              Icons.navigation,
              color: Colors.white,
            ),
          ),
          markerSize: const Size(40, 40),
          markerDirection: MarkerDirection.heading,
        ),
      );
    }
    
  5. Consider using either the AnimatedLocationMarkerLayer or the LocationMarkerLayer if multiple location markers need to be displayed.

Examples

  1. Marker Customization: Change the marker to any widget you want.

  2. Floating Action Button to Follow Current Location: Use a floating action button to move and zoom the map to the current location.

  3. Change Geolocator Settings: Define Geolocator settings yourself.

  4. Selectable Distance Filter: Change Geolocator settings at runtime.

  5. Custom Stream: Use your own stream, such as position stream from another library or predefined route, as the source.

  6. No Stream: Use Flutter setState() to update position and heading.

  7. Navigation Mode: Rotate the map to keep heading pointing upward.

  8. Default Stream: Share the default streams between your app and this plugin.

FAQ

Q: How can I get the positionStream , headingStream or their origin streams from a CurrentLocationLayer widget?

A: You should not get these streams from a CurrentLocationLayer widget. Instead, create your own streams with the same types and also pass them to all widgets that need them. CurrentLocationLayer doesn't own the streams; it just listens to them. You can use any implementation of position and heading streams, as long as the stream types are Stream<LocationMarkerPosition?> and Stream<LocationMarkerHeading?>, respectively. You may see this example to know about how to do this.

所屬分類

依賴

依賴清單 4 項

原始碼儲存庫

使用此套件的專案