[OpenLayers-Dev] Problem with cluster strategy
Jerome Freyre
jerome.freyre at hispeed.ch
Wed Nov 26 09:02:03 EST 2008
Hi everybody,
In my project, I currently use the cluster strategy.
In the example
http://dev.openlayers.org/sandbox/vector-behavior/examples/strategy-cluster.html
we use a little formula in the context to define the radius :
Math.min(feature.attributes.count, 7) + 3;
Personnally, I am not sure that it is the right way to define the radius
size of the cluster.
Normally, the radius should be defined by the "max value of all cluster" and
the "max radius we autorize"!?
Personally, I add a function in the Cluster.js file which is called before
the this.layer.addFeatures(clusters) in the cluster function :
getBiggestClusterValue: function(clusters) {
if (this.maxVal == -1) {
if(clusters) {
for(var i=0; i<clusters.length; ++i) {
if (clusters[i].attributes.count > this.maxVal)
this.maxVal =
clusters[i].attributes[this.AttributeUsedToCount];
}
}
return this.maxVal;
}
else
return this.maxVal;
},
And in the context, I use this formula to determine the radius
var maxClustersValue = parseInt(clusterStrategy.maxVal);
var maxRadius = 18;
var currentClusterValue = feature.attributes.nbOfSpams;
var radius = Math.ceil(currentClusterValue * (maxRadius /
maxClustersValue));
return Math.max(2,radius);
Is my reflexion correct?
Thanks all,
Jérome
--
View this message in context: http://www.nabble.com/Problem-with-cluster-strategy-tp20701364p20701364.html
Sent from the OpenLayers Dev mailing list archive at Nabble.com.
More information about the Dev
mailing list