I am trying to set style to my WMS layer in my script like this :
http://opendem.info/ol3/wms_sld.html
but I got nothing.
This is my code :
var sldBody = 'opengeo_arbousiers2 A azure polygon style azure polygon #0033cc ';
var map = new ol.Map({
layers: [ new ol.layer.Image({
source: new ol.source.ImageWMS({
url: 'http://localhost:8080/geoserver/opengeo/wms',
params: {'LAYERS': 'opengeo:regions1','SLD_BODY' :sldBody},
serverType: 'geoserver'
})})],
target: document.getElementById('map'),
view: new ol.View({
center: [-1095791.453557, 3422374.879112],
maxZoom: 19,
zoom: 5
})
});
Answer
You are attempting to use SLD in library mode which imposes some additional rules on the operation from normal.
So assuming that your SLD is valid and works when used normally, you must ensure that your request contains the name of the layer and the name of the style and that this matches the names in the SLD file you provide or isDefault
is set to true.
In your request you don't specify a Style name nor do you set isDefault
in the SLD, you also don't have matching layer names (opengeo:regions1
vs opengeo_arbousiers2
) so GeoServer will ignore the SLD you have provided.
No comments:
Post a Comment