SINTEF-9012 / PruneCluster

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

Removing Marker keeps the _removeFlag to true #116

Closed Cadrach closed 8 years ago

Cadrach commented 8 years ago

Hi all,

First, thanks for such a great library!

In a project where we are implementing it, we have come accross an issue when removing a PruneCluster.Marker

Without getting into too much detail, in our project we manage multiple Pruneclusters for the same map, each of them holding parts of a set of markers. Some markers are shared between the clusters.

What happens is, when a marker is removed from a cluster, it is marked with a flag "_removeFlag" set to true.

The issue is that this flag is never removed, even after the cluster has removed the flag from its display, and if another cluster is using the same flag, it will remove it too on its next "RemoveMarkers" call.

I provided a fix from my fork, if you can merge it it would be nice :) Pull Request: https://github.com/SINTEF-9012/PruneCluster/pull/117

(I am new to TypeScript, so feel free to modify the PR before merging it!)

fungiboletus commented 8 years ago

Hei,

Thanks for the pull-request :-) I didn't think about this use case when I implemented the _removeFlag system. Except this issue, it's interesting to see that you can use the same objects across multiple maps. I merged the pull-request.

Cadrach commented 8 years ago

Yes, it is very useful. In my case, I am using it to allow the user to "extract" some markers from the main PruneCluster. Basically it allows them to remove a category from the clustering, and display it in a PruneCluster with -1 Size & Margin, but I can keep the same filtering system.

fungiboletus commented 8 years ago

Is the -1 Size&Margin hack fast enough ? I never tried it and I'm amazed that it doesn't crash :d

Cadrach commented 8 years ago

It depends how many markers you have to display. In order to perform correctly, I have setup a way to estimate how many markers will be shown before calling Processview. So I am able to remove the Markers from the "low margin" cluster and put them back into the "high margin" cluster before display.

Currently at around 1000 markers it works correctly. Pushing it further could be done with more and more loss of performance the more the markers you show.

fungiboletus commented 8 years ago

If you can have up to 1000 markers, it's not so bad. More than this might be slow due to the DOM tree manipulations and the rendering.

Cadrach commented 8 years ago

On a previous iteration of the project we were rendering up to 5000, but it was indeed very slow. And the usability is very low (you have like a big clump of stacked icons). The power of PruneCluster allowed us to push the number of marker to around 250000, and with the "unclustering" they show automatically if you reach lower levels with less markers in the area.