Skip to content
This repository has been archived by the owner on Jul 11, 2024. It is now read-only.

Cluster support #173

Merged
merged 4 commits into from
May 21, 2024
Merged
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
4 changes: 4 additions & 0 deletions packages/atlas/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# atlas

## v1.3.0 (2024-05-21)

- Added support for `Clustering`

## v1.2.0 (2024-05-09)

- Added enum value `threeDimensional` for `MapType`
Expand Down
1 change: 1 addition & 0 deletions packages/atlas/lib/atlas.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export 'src/camera_position.dart';
export 'src/circle.dart';
export 'src/cluster.dart';
export 'src/cluster_icon.dart';
export 'src/cluster_options.dart';
export 'src/congestion_level_route.dart';
export 'src/device_location.dart';
export 'src/heatmap/heatcolor.dart';
Expand Down
6 changes: 6 additions & 0 deletions packages/atlas/lib/src/atlas.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:atlas/atlas.dart';
import 'package:atlas/src/cluster_options.dart';
import 'package:flutter/widgets.dart';

/// `Atlas` is a Flutter [Widget] which abstracts the underlying map provider
Expand Down Expand Up @@ -145,6 +146,9 @@ class Atlas extends StatelessWidget {
/// Callback executed when the map is loaded and is on the screen
final Heatmap? heatmap;

/// Clusters the markers into groups
final ClusterOptions? clusterOptions;

Atlas({
Key? key,
required this.initialCameraPosition,
Expand Down Expand Up @@ -179,6 +183,7 @@ class Atlas extends StatelessWidget {
this.onPolylineTap,
this.onMapLoaded,
this.heatmap,
this.clusterOptions,
}) : markers = markers ?? Set<Marker>(),
callouts = callouts ?? Set<Callout>(),
circles = circles ?? Set<Circle>(),
Expand Down Expand Up @@ -229,6 +234,7 @@ class Atlas extends StatelessWidget {
onPolylineTap: onPolylineTap,
onMapLoaded: onMapLoaded,
heatmap: heatmap,
clusterOptions: clusterOptions,
);
}
}
25 changes: 25 additions & 0 deletions packages/atlas/lib/src/cluster_options.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import 'package:atlas/atlas.dart';
import 'package:flutter/widgets.dart';

/// Cluster customization
class ClusterOptions {
/// Whether to cluster the markers into groups
final bool enabled;

/// Called when a cluster is tapped.
/// The Markers of the pressed cluster are passed as an argument.
final ValueChanged<Set<Marker>>? onTap;

/// Icon used for the clustered markers
final MarkerIcon icon;

/// Text color of the cluster counter
final Color textColor;

ClusterOptions({
this.enabled = true,
this.onTap,
required this.icon,
required this.textColor,
});
}
3 changes: 3 additions & 0 deletions packages/atlas/lib/src/provider.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import 'package:atlas/atlas.dart';
import 'package:flutter/widgets.dart';

import 'cluster_options.dart';

/// Callback function taking a single argument.
typedef void ArgumentCallback<T>(T argument);

Expand Down Expand Up @@ -49,5 +51,6 @@ abstract class Provider {
final double? maxZoom,
final VoidCallback? onMapLoaded,
final Heatmap? heatmap,
final ClusterOptions? clusterOptions,
});
}
2 changes: 1 addition & 1 deletion packages/atlas/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: atlas
description: An extensible map abstraction for Flutter with support for multiple map providers
version: 1.2.0
version: 1.3.0
repository: https://github.com/bmw-tech/atlas
issue_tracker: https://github.com/bmw-tech/atlas/issues
homepage: https://bmw-tech.github.io/atlas
Expand Down
Loading