sharewire / google-maps-clustering

Fast marker clustering library for Google Maps Android API.
Apache License 2.0
292 stars 77 forks source link

Cluster range / min cluster size #7

Closed meierjan closed 6 years ago

meierjan commented 6 years ago

Hey, thank you for writing this library - google maps utils really lacks maintainers...

I wonder if it's possible to change the range of the clusters. I've just seen the screenshots and the clusters seem very far apart.

Thanks in advance.

makovkastar commented 6 years ago

Hi @meierjan. There is no public API in the library to change this, but you can modify the source code. Find the method ClusterManager.getClusters(...) and increase the value of the tileCount variable (line 138). The higher the value, the closer clusters will be to each other.

For example I changed it to this: long tileCount = (long) (Math.pow(2, zoomLevel) * 4); and the result is the following:

device-2018-01-30-122623

meierjan commented 6 years ago

Hey, thanks for the heads up. I dug into the source code and found exactly this spot. How do you feel about adding this to the public api? Maybe I can provide a PR

makovkastar commented 6 years ago

How would you name the method for setting this value?

meierjan commented 6 years ago

I will read the source-code completely to understand what actually happens under the hood and then come back with a naming idea. I saw quad-trees so something like grid-size was my first intention.

makovkastar commented 6 years ago

I feel like grid-size is too technical and exposes the internal implementation details. If you have other ideas, please let me know.

meierjan commented 6 years ago

After thinking for a while what I really wanted was a minimum cluster size. Like not render them as clusters if there a less then X markers in the bucket. So you are free to close this issue if you don't think a "grid-size" is a good feature.

meierjan commented 6 years ago

I did it like this. Maybe you have some thoughts: https://github.com/meierjan/google-maps-clustering/pull/1/files

makovkastar commented 6 years ago

The minimum cluster size is a good candidate to add to the public API. Please send a pull request and I will take a look.