On Wed, 2008-11-05 at 11:25 +0100, Didrik Pinte wrote: > Hi, > > How is it possible to a Filter.Comparison on clustered layer based on > the feature attributes ? Looking through the code, it seems impossible > because the cluster strategy hiddes the feature attributes by the > cluster attribute (the count property). Would there be an easy and clean > solution to this problem ? > > Didrik
Here is a not really elegant solution.
When a cluster counts more than one feature, the only attribute
interesting is count. When the cluster counts only one attribute, we
could be interested by the feature attributes. Thus, when the cluster is
created, I just copy the feature attributes to the cluster. There is
only one line of code added (extending cluster.attributes using
feature.attributes)
OpenLayers/Strategy/Cluster.js - line 250
--------------------------------------------------------------------------------
createCluster: function(feature) {
var center = feature.geometry.getBounds().getCenterLonLat();
var cluster = new OpenLayers.Feature.Vector(
new OpenLayers.Geometry.Point(center.lon, center.lat),
{count: 1}
);
OpenLayers.Util.extend(cluster.attributes, feature.attributes);
cluster.cluster = [feature];
return cluster;
},
--------------------------------------------------------------------------------
The only problem could be when the feature already has a count
attribute ...
Didrik
signature.asc
Description: This is a digitally signed message part
_______________________________________________ Users mailing list [email protected] http://openlayers.org/mailman/listinfo/users
