My code is as below and I want to apply custom SLD to layer which is working for all codes in project except this one.
function cusMap(strSld_body,talukaName){
alert(strSld_body);
var query = new ol.layer.Tile({
source : new ol.source.TileWMS({
url : 'http://192.168.6.51:8090/geoserver/VP/wms',
crossOrigin: 'anonymous',
params : {
layers : 'VP:VillageBoundary',
version : '1.1.1',SLD_BODY: strSld_body,transparent : 'true'
}
}),
});
if(query.getSource().getParams().SLD_BODY){
delete query.getSource().getParams().SLD_BODY;
}
query.getSource().updateParams({'SLD_BODY': strSld_body});
if(query.getSource().getParams().CQL_FILTER){
delete query.getSource().getParams().CQL_FILTER;
}
query.getSource().updateParams({'CQL_FILTER': "Taluka='"+talukaName+"'"}); //add the cql filter to the Layer
map.removeLayer(croppedTaluka);
map.addLayer(query);
redrawLegend();
}
Here, my layer shows SLD which is applied in GeoServer, it is not taking SLD which I have applied in code.
The SLD I want apply is as below:
<?xml version="1.0" encoding="UTF-8"?><StyledLayerDescriptor xmlns="http://www.opengis.net/sld" xmlns:ogc="http://www.opengis.net/ogc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.1.0" xmlns:xlink="http://www.w3.org/1999/xlink" xsi:schemaLocation="http://www.opengis.net/sld http://schemas.opengis.net/sld/1.1.0/StyledLayerDescriptor.xsd" xmlns:se="http://www.opengis.net/se"><NamedLayer><se:Name>Village</se:Name><UserStyle>
<se:Name>Village</se:Name><se:FeatureTypeStyle><se:Rule><se:Name>1 - 92</se:Name><se:Description><se:Title>1 - 92</se:Title></se:Description><ogc:Filter xmlns:ogc="http://www.opengis.net/ogc"><ogc:PropertyIsEqualTo><ogc:PropertyName>Village</ogc:PropertyName><ogc:Literal>Nesda Juna</ogc:Literal></ogc:PropertyIsEqualTo></ogc:Filter><se:PolygonSymbolizer><se:Fill><se:SvgParameter name="fill">#ffe5e5</se:SvgParameter></se:Fill><se:Stroke><se:SvgParameter name="stroke">#ffe5e5</se:SvgParameter><se:SvgParameter name="stroke-width">0.26</se:SvgParameter><se:SvgParameter name="stroke-linejoin">bevel</se:SvgParameter></se:Stroke></se:PolygonSymbolizer></se:Rule><se:Rule><se:Name>92 - 183</se:Name><se:Description><se:Title>92 - 183</se:Title></se:Description><ogc:Filter xmlns:ogc="http://www.opengis.net/ogc"><ogc:PropertyIsEqualTo><ogc:PropertyName>Village</ogc:PropertyName><ogc:Literal>Nesda Nava</ogc:Literal></ogc:PropertyIsEqualTo></ogc:Filter><se:PolygonSymbolizer><se:Fill><se:SvgParameter name="fill">#ffcccc</se:SvgParameter></se:Fill><se:Stroke><se:SvgParameter name="stroke">#ffcccc</se:SvgParameter><se:SvgParameter name="stroke-width">0.26</se:SvgParameter><se:SvgParameter name="stroke-linejoin">bevel</se:SvgParameter></se:Stroke></se:PolygonSymbolizer></se:Rule><se:Rule><se:Name>183 - 274</se:Name><se:Description><se:Title>183 - 274</se:Title></se:Description><ogc:Filter xmlns:ogc="http://www.opengis.net/ogc"><ogc:PropertyIsEqualTo><ogc:PropertyName>Village</ogc:PropertyName><ogc:Literal>Velavapura</ogc:Literal></ogc:PropertyIsEqualTo></ogc:Filter><se:PolygonSymbolizer><se:Fill><se:SvgParameter name="fill">#ffb3b3</se:SvgParameter></se:Fill><se:Stroke><se:SvgParameter name="stroke">#ffb3b3</se:SvgParameter><se:SvgParameter name="stroke-width">0.26</se:SvgParameter><se:SvgParameter name="stroke-linejoin">bevel</se:SvgParameter></se:Stroke></se:PolygonSymbolizer></se:Rule><se:Rule><se:Name>274 - 365</se:Name><se:Description><se:Title>274 - 365</se:Title></se:Description><ogc:Filter xmlns:ogc="http://www.opengis.net/ogc"><ogc:PropertyIsEqualTo><ogc:PropertyName>Village</ogc:PropertyName><ogc:Literal>Samau Nanavas</ogc:Literal></ogc:PropertyIsEqualTo></ogc:Filter><se:PolygonSymbolizer><se:Fill><se:SvgParameter name="fill">#ff9999</se:SvgParameter></se:Fill><se:Stroke><se:SvgParameter name="stroke">#ff9999</se:SvgParameter><se:SvgParameter name="stroke-width">0.26</se:SvgParameter><se:SvgParameter name="stroke-linejoin">bevel</se:SvgParameter></se:Stroke></se:PolygonSymbolizer></se:Rule><se:Rule><se:Name>365 - 456</se:Name><se:Description><se:Title>365 - 456</se:Title></se:Description><ogc:Filter xmlns:ogc="http://www.opengis.net/ogc"><ogc:PropertyIsEqualTo><ogc:PropertyName>Village</ogc:PropertyName><ogc:Literal>Varnoda</ogc:Literal></ogc:PropertyIsEqualTo></ogc:Filter><se:PolygonSymbolizer><se:Fill><se:SvgParameter name="fill">#ff8080</se:SvgParameter></se:Fill><se:Stroke><se:SvgParameter name="stroke">#ff8080</se:SvgParameter><se:SvgParameter name="stroke-width">0.26</se:SvgParameter><se:SvgParameter name="stroke-linejoin">bevel</se:SvgParameter></se:Stroke></se:PolygonSymbolizer></se:Rule><se:Rule><se:Name>456 - 547</se:Name><se:Description><se:Title>456 - 547</se:Title></se:Description><ogc:Filter xmlns:ogc="http://www.opengis.net/ogc"><ogc:PropertyIsEqualTo><ogc:PropertyName>Village</ogc:PropertyName><ogc:Literal>Laxmipura</ogc:Literal></ogc:PropertyIsEqualTo></ogc:Filter><se:PolygonSymbolizer><se:Fill><se:SvgParameter name="fill">#ff6666</se:SvgParameter></se:Fill><se:Stroke><se:SvgParameter name="stroke">#ff6666</se:SvgParameter><se:SvgParameter name="stroke-width">0.26</se:SvgParameter><se:SvgParameter name="stroke-linejoin">bevel</se:SvgParameter></se:Stroke></se:PolygonSymbolizer></se:Rule><se:Rule><se:Name>547 - 638</se:Name><se:Description><se:Title>547 - 638</se:Title></se:Description><ogc:Filter xmlns:ogc="http://www.opengis.net/ogc"><ogc:PropertyIsEqualTo><ogc:PropertyName>Village</ogc:PropertyName><ogc:Literal>Dama</ogc:Literal></ogc:PropertyIsEqualTo></ogc:Filter><se:PolygonSymbolizer><se:Fill><se:SvgParameter name="fill">#ff4d4d</se:SvgParameter></se:Fill><se:Stroke><se:SvgParameter name="stroke">#ff4d4d</se:SvgParameter><se:SvgParameter name="stroke-width">0.26</se:SvgParameter><se:SvgParameter name="stroke-linejoin">bevel</se:SvgParameter></se:Stroke></se:PolygonSymbolizer></se:Rule><se:Rule><se:Name>638 - 729</se:Name><se:Description><se:Title>638 - 729</se:Title></se:Description><ogc:Filter xmlns:ogc="http://www.opengis.net/ogc"><ogc:PropertyIsEqualTo><ogc:PropertyName>Village</ogc:PropertyName><ogc:Literal>Jorapura</ogc:Literal></ogc:PropertyIsEqualTo></ogc:Filter><se:PolygonSymbolizer><se:Fill><se:SvgParameter name="fill">#ff1a1a</se:SvgParameter></se:Fill><se:Stroke><se:SvgParameter name="stroke">#ff1a1a</se:SvgParameter><se:SvgParameter name="stroke-width">0.26</se:SvgParameter><se:SvgParameter name="stroke-linejoin">bevel</se:SvgParameter></se:Stroke></se:PolygonSymbolizer></se:Rule></se:FeatureTypeStyle></UserStyle></NamedLayer></StyledLayerDescriptor>
Here, I have found that the HTTPRequest GET calls are not reaching GeoServer when large SLD is built dynamically in code. Can I make post calls in ol.source.TileWMS?