PruneCluster icon indicating copy to clipboard operation
PruneCluster copied to clipboard

Question: Cluster by distance

Open HunterJS-bit opened this issue 3 years ago • 4 comments

First off all thank you for a great plugin :), second I have question regarding this plugin, does it support clustering by distance in meters ?

HunterJS-bit avatar Oct 26 '20 22:10 HunterJS-bit

Thanks. It hasn't been maintained for a while unfortunately.

It doesn't support clustering by distance in meters. The main difficulty is with the classic web mercator projection (WGS84), the scale is not the same everywhere in the world. There is a huge difference between the equator line and the north or the south of the world. At the same time, this library uses a fixed grid everywhere in the world. Not having a fixed grid would mean writing a new library.

If you zoom though, like at a city zoom level, the differences are not significant and you could compute how many pixels your distance in meters is, using the right projection in this part of the world at this zoom level, and then change the cluster size dynamically.

fungiboletus avatar Oct 27 '20 09:10 fungiboletus

@fungiboletus Thank you so much for answering :+1: , Do you know any other library that has this functionality ? How could I do that what you described, do you have any code sample? I'm a bit noob

HunterJS-bit avatar Oct 27 '20 11:10 HunterJS-bit

Sorry I don't know any library with this functionality. About what I described, it's not super easy to implement with leaflet so I would recommend to continue looking for a library with this functionality.

fungiboletus avatar Oct 27 '20 12:10 fungiboletus

@fungiboletus Thank you for you answer :)

HunterJS-bit avatar Oct 27 '20 23:10 HunterJS-bit