diff --git a/packages/atlas/CHANGELOG.md b/packages/atlas/CHANGELOG.md index 1c4d95d..a019ccb 100644 --- a/packages/atlas/CHANGELOG.md +++ b/packages/atlas/CHANGELOG.md @@ -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` diff --git a/packages/atlas/lib/atlas.dart b/packages/atlas/lib/atlas.dart index f6f16ca..ff9c380 100644 --- a/packages/atlas/lib/atlas.dart +++ b/packages/atlas/lib/atlas.dart @@ -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'; diff --git a/packages/atlas/lib/src/atlas.dart b/packages/atlas/lib/src/atlas.dart index 4db9be4..7362bb9 100644 --- a/packages/atlas/lib/src/atlas.dart +++ b/packages/atlas/lib/src/atlas.dart @@ -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 @@ -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, @@ -179,6 +183,7 @@ class Atlas extends StatelessWidget { this.onPolylineTap, this.onMapLoaded, this.heatmap, + this.clusterOptions, }) : markers = markers ?? Set(), callouts = callouts ?? Set(), circles = circles ?? Set(), @@ -229,6 +234,7 @@ class Atlas extends StatelessWidget { onPolylineTap: onPolylineTap, onMapLoaded: onMapLoaded, heatmap: heatmap, + clusterOptions: clusterOptions, ); } } diff --git a/packages/atlas/lib/src/cluster_options.dart b/packages/atlas/lib/src/cluster_options.dart new file mode 100644 index 0000000..d9a9347 --- /dev/null +++ b/packages/atlas/lib/src/cluster_options.dart @@ -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>? 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, + }); +} diff --git a/packages/atlas/lib/src/provider.dart b/packages/atlas/lib/src/provider.dart index 4d9055b..699d631 100644 --- a/packages/atlas/lib/src/provider.dart +++ b/packages/atlas/lib/src/provider.dart @@ -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 argument); @@ -49,5 +51,6 @@ abstract class Provider { final double? maxZoom, final VoidCallback? onMapLoaded, final Heatmap? heatmap, + final ClusterOptions? clusterOptions, }); } diff --git a/packages/atlas/pubspec.yaml b/packages/atlas/pubspec.yaml index cb23388..3b5f10c 100644 --- a/packages/atlas/pubspec.yaml +++ b/packages/atlas/pubspec.yaml @@ -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