SINTEF-9012 / PruneCluster

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

Weight example #159

Closed sarocht closed 6 years ago

sarocht commented 6 years ago

I'm not sure, Is this duplicate from the link https://github.com/SINTEF-9012/PruneCluster/issues/17

There's data look like below shop, number of transaction, Lat , Lng A 10 10.001 12.001 B 20 10.002 12.002 C 30 10.003 12.003 When I zoom out until they gather into a cluster, It should display the total number of transaction or 60 by weighting them Can weighting feature do this?

I already try this example

for (var i = 0; i < size; ++i) {
    var marker = new PruneCluster.Marker(59.91111 + (Math.random() - 0.5) * Math.random() * 0.00001 * size, 10.752778 + (Math.random() - 0.5) * Math.random() * 0.00002 * size);

    marker.category = Math.floor(Math.random() * Math.random() * colors.length);
    // Set a random weight between 1 and 3

    marker.weight = Math.ceil(Math.random() * 3);
    markers.push(marker);
    leafletView.RegisterMarker(marker);
}

But I cannot see any differences, If remove 'marker.weight = Math.ceil(Math.random() * 3);'

Thanks in advance

fungiboletus commented 6 years ago

I'm not sure the weight feature is doing what you want. It's only used when computing the position of a cluster.

Let's say you have a point A, and a point B. By default, they both have a weight of 1.0 and the cluster will be located at equal distance. If you change the weight of B to 100, the cluster will be located a lot closer to B.

It's actually not very useful.