ClusterManager<T extends ClusterableItem> class
Manages clustering of map items based on zoom level and proximity.
This is the main class you'll use to add clustering functionality to your map. It handles the clustering algorithm, icon generation, and marker creation.
Example:
final manager = ClusterManager<MyLocation>(
items: myLocations,
config: ClusterConfig(radius: 150),
);
// Get markers for current zoom
final markers = await manager.getMarkers(
zoom: 12,
bounds: mapBounds,
);
// Update map with markers
setState(() {
_markers = markers;
});
Constructors
-
ClusterManager({required List<
T> items, ClusterConfig? config, ClusterIconPainter? painter})
Properties
- config → ClusterConfig
-
Configuration for clustering behavior
final
- hashCode → int
-
The hash code for this object.
no setterinherited
-
items
→ List<
T> -
All items that can be clustered
final
- painter → ClusterIconPainter
-
Painter for creating cluster and item icons
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
clearCache(
) → void - Clear the icon cache
-
getMarkers(
{required double zoom, LatLngBounds? bounds, bool forceRecalculate = false, dynamic onMarkerTap(String markerId, T item)?, dynamic onClusterTap(String clusterId, ClusterItem cluster)?}) → Future< Set< Marker> > - Gets markers for the current zoom level and bounds.
-
getStats(
) → Map< String, int> - Get the current number of visible clusters and items
-
invalidate(
) → void - Force recalculation of clusters
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited