Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How can I dynamically change a SLD style of a WMS layer being served by GeoServer from PostGIS?

share|improve this question
up vote 2 down vote accepted

I've found an answer in

It solved my problem. Example:

  var tiled = new OpenLayers.Layer.WMS ("state","http://localhost:8080/geoserver/wms", {......})

 tiled.mergeNewParams({SLD :some_sld_url }); 

If layer already had styles specified by "Styles" property, then you have to set it to null:

tiled.mergeNewParams({ SLD: some_sld_url, STYLES: null });

There is no need to redraw the layer. "mergeNewParams" will do it.

share|improve this answer
What link should I use? Should I save the SLD in a XML file and then use the path to this file? Or there is a link which can get through the geoserver platform (related to this SLD)? – user1919 Jun 3 '15 at 7:51

Your Answer


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.