搜索插件、代码仓与 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);

所属分类

源码仓库

使用此插件的项目