[Users] rules on cluster features
François Boussuges
f.boussuges at gmail.com
Fri May 28 10:07:04 CEST 2010
Hello,
I have a cluster WFS layer and I apply an variable 'radius' and
'fillcolor' with a context:
var context = {
fillColor: function(feature) {
if(feature.cluster) {
sens_hor= parseFloat(0)
for(var c = 0; c < feature.cluster.length; c++)
sens_hor=sens_hor+parseFloat(feature.cluster[c].attributes.SPIRALE_GOUSSE_HORAIRE)
result=sens_hor/feature.cluster.length
if(result > 50) return "#990000";
if(result<=50) return "#000099";}
} ,
label: function(feature) {
if(feature.cluster) {
sens_hor= parseFloat(0)
for(var c = 0; c < feature.cluster.length; c++)
sens_hor=sens_hor+parseFloat(feature.cluster[c].attributes.SPIRALE_GOUSSE_HORAIRE)
result=sens_hor/feature.cluster.length
return result;}},
radius: function(feature) { var pix = 3; if(feature.cluster) { pix =
Math.min(feature.attributes.count, 7) *2; } return pix;}};
var defStyle1 = new OpenLayers.Style({
pointRadius: "${radius}",
fillColor: "${fillColor}",
fillOpacity:1,
strokeColor: "#FFFF00",
strokeWidth: 1,
strokeOpacity: 1 }
/* context pour le cluster */
,{ context: context}
);
This is ok but I want to use Openlayers.Rules and filter to add rules on
my style and display the legend of my layer (with GeoExt.LegendPanel).
But when I try to add rule with 'label' propertie the color is not display:
defStyle1.addRules =([new OpenLayers.Rule( {
title: "<50% spirale horaire",
context: context,
symbolizer : {
fillColor : "#990000",
},
filter : new OpenLayers.Filter.Comparison({
type : OpenLayers.Filter.Comparison.LESS_THAN_OR_EQUAL_TO,
property: "${label}",
value:50
})
}), new OpenLayers.Rule( {
title: ">50% spirale antihoraire",
context: context,
symbolizer : {
fillColor : "#000099"
},
filter : new OpenLayers.Filter.Comparison({
type : OpenLayers.Filter.Comparison.GREATER_THAN,
property: "${label}",
value:50
})
})]);
Have you an idea?
Thank you
More information about the Users
mailing list