SINTEF-9012 / PruneCluster

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

Cluster never updated if only categories changed. #156

Open m-ves opened 6 years ago

m-ves commented 6 years ago

I found that cluster categories colors never updated if only marker's categories were changed, while population and marker's positions stayed unchanged.

To check it just change window.setInterval in random.10000-categories.html example in the next way:

window.setInterval(function () {
    for (i = 0; i < size / 2; ++i) {
        markers[i].category = Math.floor(Math.random() * Math.random() * colors.length);
    }
    leafletView.ProcessView();
}, 500);
fungiboletus commented 6 years ago

Thanks for the bug report, I can confirm it.

I didn't really thought about dynamic categories when I implemented the cache, so it's not an obvious fix. Could you remove and add again the markers, or is it too slow ?

m-ves commented 6 years ago

I found the solution by controlling of categories array for changes. It works very well, but I can't do "Pull request". So I attach updated file here. Please check the solution and implement it if it is right. PruneCluster.zip