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

averaged center of cluster #5

Open
marimil opened this issue Apr 9, 2012 · 3 comments
Open

averaged center of cluster #5

marimil opened this issue Apr 9, 2012 · 3 comments

Comments

@marimil
Copy link

marimil commented Apr 9, 2012

Please implement the calculation of coordinates of the marker cluster as the average of the coordinates of the markers that belong to the cluster.

In this example http://z-lowicza.pl/mapy/c is drawn incorrectly.

@ideak
Copy link
Owner

ideak commented Apr 10, 2012

Hi, thanks for pointing this out. Yes, this is a known limitation due to the simple way how cluster centers are calculated at the moment. The center will be the position of the first marker added to the cluster. Since this first marker will depend on the current zoom level (which determines the view boundaries and the visible markers), it's somewhat random how clusters are formed in different zoom levels. Also there can be different definitions of "center". One close to intuition would be one calculated with some weighted algorithm which would put the center in the densest spot. But at the moment this again is not so, the center will be just the very first marker the script encounters that can't be put in a pre-existing cluster and so will create a new cluster.

The solution I was thinking of is to pre-calculate the clusters per zoom level, but I haven't yet gotten down to the details of how to implement it.

@marimil
Copy link
Author

marimil commented Apr 10, 2012

In this code
google-maps-utility-library-v3.googlecode.com/svn/trunk/markerclusterer/src/markerclusterer.js
averageCenter variable is implemented. Maybe this will help.
Link to the example:
google-maps-utility-library-v3.googlecode.com/svn/trunk/markerclusterer/examples/advanced_example.html
Sometimes, however, markers disappear.

@ideak
Copy link
Owner

ideak commented Apr 12, 2012

marimil: thanks, I will look at that implementation, try to track down the bug you mentioned and port it. If you can help patches are welcome! :)

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