I want to show markers on the map in a manner similar to this example, but I have more markers and I want to use "native" Google Map.
So far I have found only 1 library that looked like capable of doing this: android-maps-utils. But after testing I discovered that it has serious performance problems when there are about 35000 markers. (and even java.lang.OutOfMemoryError
). So I'm wondering which other options are out there. Rolling my own solution from scratch is probably the last thing I want to do.
I guess, that library isn't going to be usable at all with very large marker counts, because it keeps them all in RAM. It might be better to filter out currently invisible markers while reading them from a file, for example, and do it after each camera movement. (Reading 35k pairs of double
from binary file via DataInputStream
was pretty fast, so this isn't a big deal right now. And I guess this can be accelerated even further.) Also, I can prepare preprocessed sets of clusters for different zoom levels in different files, because markers are not going to change frequently.
But implementing this from scratch (especially — proper clustering) looks like a lot of work. Maybe I'm missing something that already does it?
Update
I tried using android-maps-extensions for this purpose. It works better, but it keeps all markers in memory too, and when displaying about 35k markers it results in ~20MB memory consumption when completely zoomed out, and ~24MB when zoomed in. Another ~7MB and there will be crashes... So I think I need to keep as little data in RAM as possible. Is there a library that works like that?