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:
Village
Village 1 - 92 1 - 92 Village Nesda Juna #ffe5e5 #ffe5e5 0.26 bevel 92 - 183 92 - 183 Village Nesda Nava #ffcccc #ffcccc 0.26 bevel 183 - 274 183 - 274 Village Velavapura #ffb3b3 #ffb3b3 0.26 bevel 274 - 365 274 - 365 Village Samau Nanavas #ff9999 #ff9999 0.26 bevel 365 - 456 365 - 456 Village Varnoda #ff8080 #ff8080 0.26 bevel 456 - 547 456 - 547 Village Laxmipura #ff6666 #ff6666 0.26 bevel 547 - 638 547 - 638 Village Dama #ff4d4d #ff4d4d 0.26 bevel 638 - 729 638 - 729 Village Jorapura #ff1a1a #ff1a1a 0.26 bevel
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?
Answer
Actually the httprequest is the problem, use Httprequest Post method instead of get method in ol.source.ImageWMS?
Get request can not pass long string parameters. For big parameters we need to pass request with post method.
Now the bottleneck is that the post method is not supported in openlayers 3 whereas in old version it had support for post method.
Note: This is old OpenLayers code
var query = new OpenLayers.Layer.WMS.Post("My Layer",
'http://192.168.6.51:8090/geoserver/VP/wms', {
LAYERS : 'Namespace:LayerName',
sld_body : strSld_body,
format : 'image/jpeg',
transparent : 'true'
},
{
unsupportedBrowsers: [],
isBaseLayer: false,
yx : {'EPSG:4326' : true}
} );
No comments:
Post a Comment