Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions lib/src/marker_cluster_layer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,13 @@ class _MarkerClusterLayerState extends State<MarkerClusterLayer>

_MarkerClusterLayerState();

bool _shouldSpiderfy(MarkerClusterNode cluster) {
return widget.options.spiderfyCluster &&
(widget.options.disableSpiderfyAboveMarkerCount <= 0 ||
cluster.markers.length <=
widget.options.disableSpiderfyAboveMarkerCount);
}

bool _isSpiderfyCluster(MarkerClusterNode cluster) {
return spiderfyCluster != null &&
spiderfyCluster!.bounds.center == cluster.bounds.center;
Expand Down Expand Up @@ -623,7 +630,7 @@ class _MarkerClusterLayerState extends State<MarkerClusterLayer>
widget.options.onClusterTap?.call(cluster);

if (!widget.options.zoomToBoundsOnClick) {
if (widget.options.spiderfyCluster) {
if (_shouldSpiderfy(cluster)) {
if (spiderfyCluster != null) {
if (spiderfyCluster == cluster) {
_unspiderfy();
Expand Down Expand Up @@ -691,7 +698,7 @@ class _MarkerClusterLayerState extends State<MarkerClusterLayer>
zoomTween.begin == zoomTween.end;

if (isAlreadyFit) {
if (cannotDivide && widget.options.spiderfyCluster) {
if (cannotDivide && _shouldSpiderfy(cluster)) {
_spiderfy(cluster);
}
return;
Expand All @@ -711,7 +718,7 @@ class _MarkerClusterLayerState extends State<MarkerClusterLayer>
..removeListener(listener)
..reset();

if (cannotDivide && widget.options.spiderfyCluster) {
if (cannotDivide && _shouldSpiderfy(cluster)) {
_spiderfy(cluster);
}
});
Expand Down
5 changes: 5 additions & 0 deletions lib/src/marker_cluster_layer_options.dart
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,10 @@ class MarkerClusterLayerOptions {
/// If false remove spiderfy effect on tap
final bool spiderfyCluster;

/// If set, spiderfy will be disabled above this marker count
/// 0 -> No limit
final int disableSpiderfyAboveMarkerCount;

/// Increase to increase the distance away that circle spiderfied markers appear from the center
final int spiderfyCircleRadius;

Expand Down Expand Up @@ -210,6 +214,7 @@ class MarkerClusterLayerOptions {
this.circleSpiralSwitchover = 9,
this.spiderfyShapePositions,
this.spiderfyCluster = true,
this.disableSpiderfyAboveMarkerCount = 0,
this.polygonOptions = const PolygonOptions(),
this.showPolygon = true,
this.onMarkerTap,
Expand Down
7 changes: 5 additions & 2 deletions pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: flutter_map_marker_cluster
description: A Dart implementation of Leaflet.makercluster for Flutter apps.
Provides beautiful animated marker clustering functionality for flutter_map.
version: 8.1.0
version: 8.2.2

homepage: https://github.com/lpongetti/flutter_map_marker_cluster

Expand All @@ -12,7 +12,10 @@ environment:
dependencies:
flutter:
sdk: flutter
flutter_map: ^8.1.1
flutter_map:
git:
url: https://github.com/ben-milanko/flutter_map.git
ref: fix/fling-rebound
flutter_map_marker_popup:
git:
url: https://github.com/enricostrijks/flutter_map_marker_popup.git
Expand Down