bpillon / google_maps_cluster_manager

Simple Flutter clustering library for Google Maps
https://pub.dev/packages/google_maps_cluster_manager
MIT License
121 stars 94 forks source link

Markerbuilder network images enhancement / question #26

Closed Martibis closed 2 years ago

Martibis commented 3 years ago

For each marker / cluster visible on the map I am converting a unique network image to a BitMapDescriptor for the Marker icon parameter. This operation can take a bit of time, I was wondering if there is a way to show a placeholder icon in some way?

If this is currently not possible, I'd like to propose the following feature: a new parameter for ClusterManager called placeholderMarkerBuilder, which is ran before markerBuilder if not null, and of which the markers are removed upon completion of markerBuilder. If there is a better way, I'd look forward to hearing it too.

Thanks for this package by the way, it's by far the best clustering package I've found on Flutter so far!

bpillon commented 3 years ago

Hello Martibis. I didn't have this type of problematic for the moment but I think you can already have a placeholder strategy. For example, you can create a cache for your BitmapDescriptors (may be with a Map<String, BitmapDescriptor> with the String being the URL of images or something else). On your marker builder, you test if your map cache contrains the URL, if not, return a placeholder and compute the BitmapDescriptor for the next time. When all the BitmapDescriptors are computed, you call updateMap() to force the update of the clusters.