MapZoneManager 是一個 Flutter 套件,旨在簡化在 Google 地圖上建立、標記和管理區域的過程。它支援多個區域,允許自訂地圖樣式,並提供精確的相機控制以實現流暢導航。適用於需要空間區域視覺化的應用,例如送貨區域、活動區域或地理圍欄。該套件可無縫整合至 Android、iOS 和 Web 平台,為開發者提供強大的互動式地圖功能解決方案。
適用情境
配送區域可視化
地理圍欄應用
事件區域規劃
互動式地圖註釋
基於位置的服務
即時區域追蹤
主要特色
多區域支援
可自訂地圖樣式
相機控制工具
區域創建工具
互動區域標記
跨平台相容性
適合對象
開發位置感知應用程式的開發者
需要基於區域的地圖互動的團隊
使用地理圍欄或配送區域的應用程式
Web 和移動地圖整合
需要動態地圖註釋的項目
使用建議
需要 Google Maps API 金鑰
僅限 Google 地圖整合
可能需要針對大量區域進行效能調校
依賴穩定的互聯網連接進行地圖渲染
Web 平台需要額外設定
原始 README
以下為關聯原始碼儲存庫的 README 原文快照,最新內容請造訪原始碼儲存庫。
MapZoneManager
MapZoneManager is a Flutter package that provides a widget and controller to manage zones on a Google Map. It allows you to create, update, and manage multiple zones, with features for handling map markers, polygons, and custom actions like adding or resetting zones. It supports both single and multi-zone management and is highly customizable with features like custom buttons and map styles.
Features
Zone Creation: Create zones by tapping on the map and adding coordinates to form a polygon.
Multiple Zones: Supports managing multiple zones on the map.
Customizable: Customize zone colors, border colors, and border width.
View-Only Mode: Ability to display zones in a read-only mode (no zone creation).
Custom Buttons: Option to replace the default add/reset zone buttons with custom widgets.
Markers & Polygons: Displays markers and polygons for each zone created on the map.
Zoom Controls: Enable/disable zoom controls and gestures.
Location Services: Enable location tracking and display of the user's current location.
Map Styles: Apply different map styles to customize the appearance of the map.
Installation
To add the package to your Flutter project, update your pubspec.yaml file:
Run flutter pub get to install the dependencies.
dependencies:
map_zone_manager: ^0.0.1
Usage
Basic Usage
To use the MapZoneManager widget, you need to add it to your widget tree. Here's a basic example:
initialCameraPosition: The initial camera position for the map (optional).
markerIcon: The icon for the markers (optional).
multiZone: Whether multiple zones can be added (default is true).
showAddButton: Whether to show the button to add a zone (default is true).
showResetButton: Whether to show the button to reset the zone (default is true).
viewOnly: Whether the map is in view-only mode (default is false).
addButtonWidget: Custom widget for the add button (optional).
resetButtonWidget: Custom widget for the reset button (optional).
zones: A list of initial zones to display on the map (optional).
onZoneAdded: A callback triggered when a new zone is added (optional).
mapStyle: The map style to apply (optional, defaults to MapStyle.standard).
mapZoneManagerController: A controller to manage map zones (optional).
minimumCoordinatesForAdding: The minimum number of coordinates required to create a zone (default is 2).
defaultZoneColor: The default fill color for zones (default is Colors.yellow).
defaultBorderColor: The default border color for zones (default is Colors.black).
defaultBorderWidth: The default border width for zones (default is 2).
currentZoneColor: The color for the current zone being created (default is Colors.red).
currentBorderColor: The color for the current zone's border (default is Colors.black).
currentBorderWidth: The width of the current zone's border (default is 2).
onTap: A callback triggered when the map is tapped (optional).
onLongPress: A callback triggered when the map is long-pressed (optional).
zoomControlsEnabled: Whether zoom controls are enabled (default is true).
zoomGesturesEnabled: Whether zoom gestures are enabled (default is true).
myLocationEnabled: Whether the user's current location is displayed (default is false).
myLocationButtonEnabled: Whether the "My Location" button is enabled (default is true).
MapZoneManagerController
The MapZoneManagerController is a controller class for managing zones and map-related operations. You can use this controller to manage zones, add coordinates, and move the camera to fit a zone.