SINTEF-9012 / PruneCluster

Fast and realtime marker clustering for Leaflet
MIT License
552 stars 131 forks source link

Question: Cluster by distance #189

Open HunterJS-bit opened 3 years ago

HunterJS-bit commented 3 years ago

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

fungiboletus commented 3 years ago

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.

HunterJS-bit commented 3 years ago

@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

fungiboletus commented 3 years ago

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.

HunterJS-bit commented 3 years ago

@fungiboletus Thank you for you answer :)