Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cluster positions #52

Open
matthewkrueger opened this issue Jul 23, 2017 · 3 comments
Open

Cluster positions #52

matthewkrueger opened this issue Jul 23, 2017 · 3 comments

Comments

@matthewkrueger
Copy link

Hey there! We had a few back and forths on SO way back when Google Maps v2 came out for Android (I'm discdev on SO) and I finally got to add your library to my app - it's awesome! So much faster than the android maps utils one from google when you turn on the dynamic option.

The one thing I'm having trouble doing is specifying the position of the clusters. I have about 5k markers in the US and 2k outside of the US. When I zoom out to the min zoom level, the 5k clusters in the US are showing in Cuba, Mexico, and Canada - it makes it look like there is nothing at all in the US, when 99% of the markers contained in the cluster is in the US.

Is there a way that I could get the clusters to place themselves closer to the "avg" lat/long of the markers within the cluster?

Thanks much!

@matthewkrueger
Copy link
Author

Here's a screenshot.
maciej

@mg6maciej
Copy link
Owner

Hello Matthew,

The only thing you may try using API of the library is to change grid size by calling ClusteringSettings::clusterSize. Making grid smaller will will surely put some clusters inside US. You may even try to find some "perfect" number for it if your data is mostly static, even if coming from your backend.

If you want, you may see grid drawn by changing DEBUG_GRID to true
https://github.com/mg6maciej/android-maps-extensions/blob/develop/android-maps-extensions/src/main/java/com/androidmapsextensions/impl/GridClusteringStrategy.java#L39 and see how it divides.

If you want to fiddle with code a bit more, it should be fairly easy to calculate weighted cluster position. Just modify calculateClusterPositon for your needs. If you do, you may also post your algo here and I might add it as an alternative for current algo.

@matthewkrueger
Copy link
Author

I ended up using the clusterSize parameter, which did a good enough job for my purposes. Feel free to close this one!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants