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

fluster 封面
套件詳情v1.2.0

fluster

一個用於 Dart 的地理空間點聚類庫,幫助在地圖解決方案中提供標記之間的間距。

AndroidiOSWebmacOSWindowsLinux
近 30 天下載
1.4萬
喜歡數
134
Pub 分數
150

安裝套件

flutter pub add fluster

套件介紹

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

Fluster 是一個用於 Dart 的地理空間點聚類函數庫,專為高效分組與管理地圖應用中的地圖標記而設計。它能根據縮放級別和空間鄰近性動態聚類點,以避免標記過度擁擠。適用於大型資料集的地圖效能優化,Fluster 可確保跨平台的流暢使用者體驗。此函數庫可無縫整合至 Flutter 應用,並支援 Android、iOS、Web、macOS、Windows 與 Linux 等多個平台。

適用情境

  • 大規模地圖標記可視化
  • 即時位置追蹤,資料密集
  • 映射UI中的性能優化
  • 基於縮放級別的動態聚類
  • 基於地圖的分析儀表板

主要特色

  • 高效的空域聚類算法
  • 縮放級別自適應聚類
  • 跨平台支援(Android、iOS、Web、macOS、Windows、Linux)
  • 輕量且快速處理
  • 與Flutter地圖組件輕鬆整合

適合對象

  • 開發互動地圖的開發者
  • 具有高密度位置資料的應用程式
  • 基於位置的服務需要性能
  • 使用 Google 地圖或類似外掛的 Flutter 開發人員
  • 需要可擴展標記管理的項目

使用建議

  • 最適合靜態或半靜態資料集
  • 可能需要針對極高頻率的更新進行調整
  • 僅限點群集(不包括多邊形或線要素)
  • 依賴於準確的座標輸入
  • 未針對離線聚類場景進行優化

原始 README

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

Build Status Pub

Fluster = Flutter + Cluster

A geospatial point clustering library for Dart (Flutter not actually required). The algorithm is a Dart port of supercluster.

Image

Usage

Implement Clusterable

Fluster will cluster a List of objects that conform to the Clusterable abstract class, which includes necessary information such as latitude and longitude:

class MapMarker extends Clusterable {
  String locationName;
  String thumbnailSrc;

  MapMarker(
      {this.locationName,
      latitude,
      longitude,
      this.thumbnailSrc,
      isCluster = false,
      clusterId,
      pointsSize,
      markerId,
      childMarkerId})
      : super(
            latitude: latitude,
            longitude: longitude,
            isCluster: isCluster,
            clusterId: clusterId,
            pointsSize: pointsSize,
            markerId: markerId,
            childMarkerId: childMarkerId);
}
Set up Fluster

Create a Fluster instance once you have a set of points you'd like to cluster:

List<MapMarker> markers = getMarkers();

Fluster<MapMarker> fluster = Fluster<MapMarker>(
      minZoom: 0,
      maxZoom: 20,
      radius: 150,
      extent: 2048,
      nodeSize: 64,
      points: markers,
      createCluster: (BaseCluster cluster, double longitude, double latitude) {
        return MapMarker(
            markerId: cluster.id.toString(),
            latitude: latitude,
            longitude: longitude);
      });

Parameters:

/// Any zoom value below minZoom will not generate clusters.
int minZoom;

/// Any zoom value above maxZoom will not generate clusters.
int maxZoom;

/// Cluster radius in pixels.
int radius;

/// Adjust the extent by powers of 2 (e.g. 512. 1024, ... max 8192) to get the
/// desired distance between markers where they start to cluster.
int extent;

/// The size of the KD-tree leaf node, which affects performance.
int nodeSize;

/// The List to be clustered.
List<T> points;

/// A callback to generate clusters of the given input type.
T Function(BaseCluster, double, double) createCluster;
Get the clusters

You can then get the clusters for a given bounding box and zoom value, where the bounding box = [southwestLng, southwestLat, northeastLng, northeastLat]:

List<MapMarker> clusters = fluster.clusters([-180, -85, 180, 85], _currentZoom);
Get the cluster children

You can also get the children (points and sub-clusters inside a cluster at the next zoom level, given the cluster id:

List<MapMarker> chilren = fluster.children(int clusterId);
Get the cluster points

Get only the child points (not sub-clusters) of a cluster in all the remaining zoom levels, given the cluster id:

List<MapMarker> points = fluster.points(clusterId);

所屬分類

原始碼儲存庫

使用此套件的專案