[OpenLayers-Users] Map style for WFS layer does not work

paweluz paweluz at o2.pl
Wed Jan 20 08:03:57 EST 2010


Hi 

The WFS layer does not appear on map when I try to use one of these three
style definition. First of all definition of my WFS layer:

		
	zielona_wfs = new OpenLayers.Layer.WFS(
                "Zielona Gora WFS - drogi, postgis", 
                "http://localhost:8080/geoserver/wfs?",
                {typename: 'topp:zielona_openstreets'},
                {
                    typename: 'zielona_openstreets', 
                    featureNS: 'http://www.openplans.org/topp', 
		    style: my_style,
                    extractAttributes: true
                }
	);	


I tried three approaches:

1)

         var my_style= new OpenLayers.StyleMap({
                      "default": {
			    strokeWidth : 5,
                            strokeColor : "#ff0000",
                            fillOpacity : 0.5                       
                      },
                      "select": {
			    strokeWidth : 5,
                            strokeColor : "#1faa00",                          
                            fillOpacity : 0.5
                      }
                    })


2)


			var wfsLayerStyle = OpenLayers.Util.extend({},
					OpenLayers.Feature.Vector.style['default']);
			var wfsLayerSelectStyle = OpenLayers.Util.extend({},
					OpenLayers.Feature.Vector.style['select']); 					
               
                        var wfsLineStyle = OpenLayers.Util.extend({},
wfsLayerStyle);
					wfsLineStyle.strokeWidth = 5;
					wfsLineStyle.strokeColor = "#ff0000";
					wfsLineStyle.fillOpacity = 0.5;					
				
			var wfsLineSelectStyle = OpenLayers.Util.extend({},
					wfsLayerSelectStyle);
					wfsLineSelectStyle.strokeWidth = 5;
					wfsLineSelectStyle.strokeColor = "#1f00aa";
					wfsLineSelectStyle.fillOpacity = 0.5;				

                        var lineStyles = {
                           "default": wfsLineStyle,
                           "select": wfsLineSelectStyle  
                        }; 	

                        var my_style= new
OpenLayers.StyleMap(lineStyles,{}); 


3)

                  var styleMap: new OpenLayers.StyleMap(
                     {"default": {strokeWidth : 5,strokeColor :
"#ff0000",fillOpacity : 0.5 },
                      "select":{strokeWidth : 5,strokeColor :
"#1f00aa",fillOpacity : 0.5  }
                     })


I have a line geometry on map. When I click on any link of that geometry I
would like to change its color.
When I erase the line style: my_style from the layer definition everything
works fine but only with default parameters (orange color, thin lines, when
someone clicks color changes to blue). Can anyone please help me with my
problem. What is going on?? 

Regards,
Poul

-- 
View this message in context: http://n2.nabble.com/Map-style-for-WFS-layer-does-not-work-tp4426355p4426355.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.



More information about the Users mailing list