google_maps_cluster_manager
google_maps_cluster_manager copied to clipboard
Don't cluster specific items
For example if I have user avatar on map, I don't need it to cluster, how do I do that?
For example if I have user avatar on map, I don't need it to cluster, how do I do that?
What you can do is to have 2 different sets. One for clustering items and another one for non clustering items, like this:
final Set<Marker> _nonClusteringMarkers = {};
final Set<Marker> _clusteringMarkers = {};
GoogleMap(
markers: {..._nonClusteringMarkers, ..._clusteringMarkers},
);
Create two classes like:
class Place { ... }
class ClusterPlace extends Place with ClusterItem { ... }
The Place one you use for the non clustering markers and the ClusterPlace you use for the clustering markers.
At the ClusterManager you can do something like this:
ClusterManager _initClusterManager() {
return ClusterManager<ClusterPlace>(
_items,
_updateClusteringMarkers,
markerBuilder: _markerClusterBuilder,
);
}