biodiv / anycluster

Server-side clustering of map markers for (Geo)Django
MIT License
106 stars 21 forks source link

Viewport as geojson #23

Closed lmorroni closed 10 years ago

lmorroni commented 10 years ago

Hi, Wouldn't it be better if the getCluster javascript function took a geojson representation of the viewport? It already does a conversion before calling the clusterMethod view. This would add the ability to for us to pass in a drawn polygon. I need this functionality for users who want to see clusters/placemarks for a specific area such as along a river. I am adding the Google Maps drawing library so a user can trace out a specific area of the map and only get clusters from that area. What do you think? Larry

biodiv commented 10 years ago

I agree one should be able to pass any geojson through javascript to anycluster. We have to keep in mind that anycluster expands the given viewport to the closes possible set of squares of the world grid. I think this is not necessary for a drawn polygon because with you want the contents of this exact polygon to be clustered. As the polygon does not change when panned or zoomed the clustering is easier. If we pass geojson to getCluster, which I think is a good idea, we would have to determine somehow if a world grid should be used or not. My first idea would be to pass an optional parameter to getCluster alongside the geojson which enforces the use of the exact geometry without snapping it to the world grid (this parameter would also enforce consistency between cluster count/ pins-on-viewport-count at the cost of a fixed grid). To make the amount of possible clusters consistent, the gridsize should be mathematically compared with the size of the area covered by the polygon to determine the k of the kmeans algorithm. If you have any further thoughts let me know.

I am rewriting anymals.org since a few months and will get to the maps soon, so I will have enough time to implement this feature.

biodiv commented 10 years ago

viewport now is geojson