Is there a way to pass sld env parameter with openlayers 3? It works to pass the env parameter with a normal getmap-request. Doesn´t openlayers support the env parameter? I used this example http://docs.geoserver.org/latest/en/user/styling/sld-extensions/substitution.html

The problem is that I have to style a wms based on features that occured within the last 24 hours and 4 days, so I have to pass the exact timestamps.

  • How are you passing the SLD to GeoServer, can you give an example request? – nmtoken Mar 31 '16 at 23:09

Try this...

var wmsSource = new ol.source.ImageWMS({
url: 'http://ip:port/geoserver/wms',
params: {'LAYERS': 'workspace:layername'/*,'ENV': 'key1:value1;key2:value2'*/},
serverType: 'geoserver',
crossOrigin: 'anonymous'});

var wmsLayer = new ol.layer.Image({
    source: wmsSource


//or another way is, you can specify it at the time 
// of source object creation in it's params.

you can get more information here:


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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