getMarkers method
Retrieve cluster markers
Implementation
Future<List<Cluster<T>>> getMarkers() async {
if (_mapId == null) return List.empty();
final mapBounds = await GoogleMapsFlutterPlatform.instance.getVisibleRegion(mapId: _mapId!);
final paddedBounds = await _addPadding(mapBounds);
final inflatedBounds = switch (clusterAlgorithm) {
ClusterAlgorithm.geoHash => _inflateBounds(paddedBounds),
_ => paddedBounds,
};
final visibleItems = items.where((i) {
return inflatedBounds.contains(i.location);
}).toList();
if (stopClusteringZoom != null && _zoom >= stopClusteringZoom!) {
return visibleItems.map((i) => Cluster<T>.fromItems([i])).toList();
}
List<Cluster<T>> markers;
if (clusterAlgorithm == ClusterAlgorithm.geoHash || visibleItems.length >= maxItemsForMaxDistAlgo) {
final level = _findLevel(levels);
markers = _computeClusters(visibleItems, List.empty(growable: true), level: level);
} else {
markers = _computeClustersWithMaxDist(visibleItems, _zoom);
}
return markers;
}