bcgov / smk-legacy-ui

Legacy Admin UI for the SMK has been de-supported. Please see the CLI under https://github.com/bcgov/smk for an alternative.
Apache License 2.0
8 stars 3 forks source link

'super cluster' implementation #330

Open NicoledeGreef opened 4 years ago

NicoledeGreef commented 4 years ago

To date, we've not found SMK to suffer performance-wise when clustering data, local or streamed.

We recently heard that a product under development at the BC Dev Exchange Lab found L.markerCluster to be slow and not enough to meet their needs. As such, they decided to implement clustering in their leaflet map using the super cluster product:

https://github.com/mapbox/supercluster

"yeah, the above is using the default Leaflet clusterer "L.ClusterMarkerGroup" that we found to be super slow on our data set. Mainly because it calculates the clusters for every zoom level of the map. Say if the map has 20 zoom levels and you are on level 14 it calculates clusters for 0 - 20. The reason they do that is that they assume you would supply ALL the map points in one go and they are optimizing the map for zoom in and out so as not to recalculate the clusters every time. However, for PIMS the frontend map will pass the current map extent to the API and the API will return only those points (parcels/buildings) that are within that extent. So for every pan or zoom you get a distinct dataset, which then the leaflet default clusterer goes and calculates the same thing 20 times"

This is currently not a high priority for SMK core as we've yet to come across a case of a 'simple map" that our current implementation didn't serve well enough but this is something to keep in our back pocket if needed.