PruneCluster icon indicating copy to clipboard operation
PruneCluster copied to clipboard

sometime after move markers some clusters dont work - havent markers

Open tombtom opened this issue 8 years ago • 13 comments

Hello,

great plugin, I try use it, but sometimes clusters dont work. I hope that I simulated it. In this sample after markers move, top-right cluster dont have markers. When I clicking on it nothing happens. When I zoom out/in or move markers outside screen (probably after some recomputing) it works fine.

var map = L.map("map", {
    attributionControl: false,
    zoomControl: false
}).setView(new L.LatLng(59.911111, 10.752778), 18);

L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', {
    detectRetina: true,
    maxNativeZoom: 17
}).addTo(map);

var leafletView = new PruneClusterForLeaflet(70);

var size = 15;
var markers = [];
for (var i = 0; i < size; ++i) {
    var marker = new PruneCluster.Marker(59.91111 + i * 0.00005, 10.752778 + i * 0.00005);
    markers.push(marker);
    leafletView.RegisterMarker(marker);        
}

window.setTimeout(function () {
    for (i = 0; i < size ; ++i) {
        var ll = markers[i].position;
        ll.lng +=  0.0001;
    }

    leafletView.ProcessView();
}, 1000);

map.addLayer(leafletView);

thanks for help, I really like this plugin

tombtom avatar Sep 26 '15 12:09 tombtom

Thank you for this bug report. I will look into it as soon as I have time

fungiboletus avatar Sep 28 '15 08:09 fungiboletus

I made simpler sample only with 2 markers http://jsfiddle.net/knvnp9og/7/

tombtom avatar Sep 30 '15 12:09 tombtom

Thank you for this new jsfiddle, it really helped. I think I saw this bug in my applications few times but I never took enough time to reproduce it.

About the bug itself, a cluster marker could be recycled after an update if it contains the same data and it hasn't moved a lot. But the position wasn't updated in the "click" event listener.

I tested a quick fix on the bugfix-87 branch. Can you get the compiled version and test it?

fungiboletus avatar Sep 30 '15 14:09 fungiboletus

it is much better but sometime is still some problem. number in cluster is different than number of markers in spider

tombtom avatar Sep 30 '15 18:09 tombtom

Ok, it's probably still the same problem. I will try to fix it this weekend.

fungiboletus avatar Sep 30 '15 19:09 fungiboletus

it is only few times, it take long time to find this cluster, I try make simple sample but it is hard now ;)

tombtom avatar Sep 30 '15 20:09 tombtom

http://jsfiddle.net/knvnp9og/8/ there are 2 clusters(number 3 and number 6) with 9 markers with old version cluster 3 has 0 markers and cluster 6 has 9 markers with new version cluster 3 has 3 markers and cluster 6 has 9 markers

tombtom avatar Oct 01 '15 05:10 tombtom

Hi. Thank you again for the nice jsfiddles.

I implemented few fixes and I hope that resolves the problem. You can try the updated version.

fungiboletus avatar Oct 04 '15 09:10 fungiboletus

after few tests it looks good

tombtom avatar Oct 04 '15 11:10 tombtom

after more tests it is almost OK but there is still little problem. When some clusters are near, number of markers in spider is bigger than number in cluster. one marker is in both spiders. But I think it is acceptable for now.

tombtom avatar Oct 06 '15 12:10 tombtom

I implemented an algorithm to prevent that but I may have forgot one or two situations. I will try to fix that before merging the fix to the master branch.

fungiboletus avatar Oct 07 '15 07:10 fungiboletus

OK, maybe I'll make some sample but time is what I need ;)

tombtom avatar Oct 07 '15 13:10 tombtom

I made sample but I think it is something else. http://jsfiddle.net/knvnp9og/9/ I don't know if is correct: var leafletView = new PruneClusterForLeaflet(20); leafletView.clusterMargin = 20;

tombtom avatar Oct 08 '15 18:10 tombtom