[OpenLayers-Users] Problem with OpenLayers.Rule

David Alda Fernandez de Lezea dalda at ikt.es
Wed Mar 23 10:59:12 EDT 2011


Hi,

Nevermind, it was my fault. I wasn't setting the atributes properly, so the rule couldn't be applied properly as well.
 
Regards.
 
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
··················································································

-----Mensaje original-----
De: openlayers-users-bounces at lists.osgeo.org [mailto:openlayers-users-bounces at lists.osgeo.org] En nombre de David Alda Fernandez de Lezea
Enviado el: martes, 22 de marzo de 2011 14:43
Para: users at openlayers.org
Asunto: [OpenLayers-Users] Problem with OpenLayers.Rule

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
··················································································
_______________________________________________
Users mailing list
Users at lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/openlayers-users


More information about the Users mailing list