[OpenLayers-Users] Cluster strategy : cluster coord update proposition

Didrik Pinte lists at dipole-consulting.com
Thu Dec 11 11:10:01 EST 2008


The cluster (x,y) position is created using the first feature.geometry
coordinates. To have a cluster that is "at the center" of the data it
clusters, I would propose to update its position using all the feature
added to the cluster. Something like this :

     addToCluster: function(cluster, feature) {
+        //update pos of the cluster to the mean pos of the features
+        var bounds = cluster.geometry.getBounds();
+        bounds.extend(feature.geometry.getBounds(););
         cluster.cluster.push(feature);
         cluster.attributes.count += 1;
+        cluster.geometry = bounds.getCenterLonLat();
     },

What do you think about that ? Interesting or not ? Is it worth
submitting a patch for it ?

Didrik

-- 
Didrik Pinte - Gérant/Manager

Dipole Consulting SPRL
E-mail : dpinte at dipole-consulting.com
Tel    : +32 (0)10 77 90 05
Mobile : +32 (0)475 665 668
Fax    : +32 (0)2 791 56 61
Web    : http://www.dipole-consulting.com 

TVA    : BE.0895.560.517
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: This is a digitally signed message part
Url : http://lists.osgeo.org/pipermail/openlayers-users/attachments/20081211/e462a2ae/attachment.bin


More information about the Users mailing list