android-maps-extensions
android-maps-extensions copied to clipboard
Notify when marker is declustered
Is it possible to get callback when marker is being declustered/clustered (showing as single marker or added to cluster)?
My problem is that I need to add more than 2000 markers, with custom icons. Those more than 2000 icons take a lot of memory, and on some devices app crashes. So I would like to generate/set icon only when the marker is being displayed as actual marker and not when I add them to GoogleMap.
Does it make any sense and is this possible?
I don't have an answer to your question, but if those 2000 icons are not unique, you can reuse the Bitmapdescriptor among the markers that share it to save memory.
@vit001 Yes I have implemented LruCache for BitmapDescriptors, but those 2000 icons are unique, that's why it would be great if a feature like this would be available
@kaads123 I can't help with your question, but do you have a link to an example for using LruCache for custom icons (BitmapDescriptors)? I'm trying to optimize my map with over 2000 markers, most of which have the same icon.
@zerox1212 sure, this should be enough. https://developer.android.com/topic/performance/graphics/cache-bitmap.html There's also a code sample how to implement it. In the sample it caches Bitmaps, but in your case you will cache BitmapDescriptors. Also in the sample it uses size of Bitmaps in b, you can just provide a number of items in cache.