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
Answer
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.
No comments:
Post a Comment