[OpenLayers-Users] Problem with OpenLayers.Rule
David Alda Fernandez de Lezea
dalda at ikt.es
Tue Mar 22 09:43:12 EDT 2011
Hi list,
I'm having some troubles while applying an OpenLayers.Rule to a styleMap.I've got an OpenLayers.Layer.Vector with the following styleMap:
var styles = new OpenLayers.StyleMap({
"default": new OpenLayers.Style(null, {
rules: [
new OpenLayers.Rule({
elseFilter: true,
symbolizer: {
"Point": {
pointRadius: 5,
graphicName: "circle",
fillColor: "#FFA500",
fillOpacity: 0.25,
strokeWidth: 1,
strokeOpacity: 1,
strokeColor: "#FFA500"
},
"Line": {
strokeWidth: 3,
strokeOpacity: 1,
strokeColor: "#FFA500"
},
"Polygon": {
strokeWidth: 2,
strokeOpacity: 1,
strokeColor: "#FFA500",
fillColor: "#FFA500"
}
}
})
]
}),
"select": new OpenLayers.Style({
strokeColor: "#00ccff",
strokeWidth: 4
}),
"temporary": new OpenLayers.Style(null, {
rules: [
new OpenLayers.Rule({
symbolizer: {
"Point": {
pointRadius: 5,
graphicName: "square",
fillColor: "white",
fillOpacity: 0.25,
strokeWidth: 1,
strokeOpacity: 1,
strokeColor: "#333333"
},
"Line": {
strokeWidth: 3,
strokeOpacity: 1,
strokeColor: "#00ccff"
},
"Polygon": {
strokeWidth: 2,
strokeOpacity: 1,
strokeColor: "#0000ff",
fillColor: "#0000ff"
}
}
})
]
})
});
Later I will load some features, and I want them to be styled differently, so I've thought that it could be a good idea to apply an OpenLayers.Rule to them. The rule I'm trying to apply to is:
var rule = new OpenLayers.Rule({
elseFilter: true,
filter: new OpenLayers.Filter.Comparison({
type: OpenLayers.Filter.Comparison.EQUAL_TO,
property: "id",
value: scope.identificador
}),
symbolizer: scope.style
});
vectorLayer.addFeatures(features);
vectorLayer.styleMap.styles.default.addRules([rule]);
But I can't see the features styled with this new Rule. Am I doing something wrong??
Thanks.
Un saludo,
··················································································
David Alda Fernández de Lezea
Lurralde eta Biodibertsitate Saila / Dpto. de Territorio y Biodiversidad
IKT
Granja Modelo s/n · 01192 · Arkaute (Araba)
··················································································
Tlfnos.: 945-00-32-95 Fax: 945-00.32.90
··················································································
email: dalda at ikt.es web: www.ikt.es
··················································································
More information about the Users
mailing list