clustering_google_maps
clustering_google_maps copied to clipboard
How create custom cluster markers?
Hi! First - thansk for this library!
It works fine.
But I can't get how can I create my custom markers within clusters?
It looks like you create them under the hood, but it would be nice if we (lib customers) will have an opportunity to ovverride createMaker
function 😉
Right now I am using the next trik to fix it:
void _updateMarkers(Set<Marker> markers) async {
final knownMarkers = _convertToKnownMarkerSet(markers);
setState(() {
this.currentMapMarkers = knownMarkers;
});
}
Set<Marker> _convertToKnownMarkerSet(Set<Marker> clusteredMarkers) {
final Set<Marker> newMarkers = Set();
for (Marker marker in clusteredMarkers) {
final converted = _getKnownMarker(marker);
newMarkers.add(converted);
}
return newMarkers;
}
Marker _getKnownMarker(Marker newMarker) {
for (Marker marker in allMapMarkers) { //`allMapMarkers` is set of all my markers.
if (marker.position == newMarker.position) {
return marker;
}
}
return newMarker;
}
it works, but its dirty...
as proposition: it would be nice to have something similar to createFromMemory
, but instead list of LatLngAndGeohash
as param, pass list of Marker
s (which under the hood can be converted to list of LatLngAndGeohash
, if needed). Then there will be no need to override createMarker
😉
The same question about claster marker icon, it would be nice to have an opportunity to override it create func.