Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I am a complete novice with GeoServer and OpenLayers. I'm trying to ascertain at what point a style is applied to a GeoServer layer which is drawn in OpenLayers, when using an SLD.

The Introduction to SLD topic says:

When adding a layer and a style to GeoServer at the same time, the style should be added first, so that the new layer can be associated with the style immediately

which implies that the style is stored with the layer in GeoServer. Does this mean that I can't change the layer's style dynamically in OpenLayers?

The Attribute-Based Polygon example shows how to symbolize a polygon based on its attributes. Could a user change this symbology dynamically, within an OpenLayers map which is running on their browser?

The OpenLayers Styling page says:

When a feature is added to a map, its style information can come from one of three sources:

Does this mean that it would be necessary to remove a layer, and add it to the map with a new SLD, in order to change its style?

Thanks

share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

If we are talking about styling in general it differs for a WMS layer and for a feature (WFS let's say) If your layer is WMS then you have to create your sld request (you can do that dynamically) and attach it to your WMS request. Then WMS renders the layer based on your SLD. If your layer is a feature then rendering is a responsibility of the Openlayers. There you can give a style to it (so dynamically) by using the information in the link that you've given yourself (Openlayers Styling).

And about the sentence : "When adding a layer and a style to GeoServer at the same time, the style should be added first, so that the new layer can be associated with the style immediately" It is not relevant in this case. Geoserver and all WMS servers in general can render WMS layers dynamically based on your SLD request attached to the main request.

share|improve this answer
    
thanks, that's good to know –  Stephen Lead Jan 29 '12 at 19:53
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.