我正在传递SLD参数以使用openlayers3获取WMSImage,该SLD是编码的XML,但似乎编码的SLD在通过浏览器标头读取时被附加了%25进行了修改。
var Current_toets_wms = new ol.layer.Image({
source: new ol.source.ImageWMS({
url: CurrentToetskaartenurl,
params: {
LAYERS: layername,
SLD_BODY: '%3C%3Fxml+version%3D%221.0%22+encoding%3D%22ISO-8859-1%22%3F%3E%3Csld%3AStyledLayerDescriptor+version%3D%221.0.0%22+xsi%3AschemaLocation%3D%22http%3A%2F%2Fwww.opengis.net%2Fsld+StyledLayerDescriptor.xsd%22+xmlns%3D%22http%3A%2F%2Fwww.opengis.net%2Fsld%22+xmlns%3Asld%3D%22http%3A%2F%2Fwww.opengis.net%2Fsld%22+xmlns%3Aogc%3D%22http%3A%2F%2Fwww.opengis.net%2Fogc%22+xmlns%3Axlink%3D%22http%3A%2F%2Fwww.w3.org%2F1999%2Fxlink%22+xmlns%3Axsi%3D%22http%3A%2F%2Fwww.w3.org%2F2001%2FXMLSchema-instance%22%3E%3CIsDefault%3E1%3C%2FIsDefault%3E%3Csld%3ANamedLayer%3E%3Csld%3AName%3EEnkelbestemming%3C%2Fsld%3AName%3E%3Csld%3AUserStyle%3E%3Csld%3ATitle%3Egemengd%3C%2Fsld%3ATitle%3E%3Csld%3AFeatureTypeStyle%3E%3Csld%3ARule%3E%3Cogc%3AFilter%3E%3Cogc%3APropertyIsEqualTo%3E%3Cogc%3APropertyName%3Ebestemmingshoofdgroep%3C%2Fogc%3APropertyName%3E%3Cogc%3ALiteral%3Egemengd%3C%2Fogc%3ALiteral%3E%3C%2Fogc%3APropertyIsEqualTo%3E%3C%2Fogc%3AFilter%3E%3Csld%3APolygonSymbolizer%3E%3Csld%3AFill%3E%3Csld%3ACssParameter+name%3D%22fill%22%3E%23000000%3C%2Fsld%3ACssParameter%3E%3Csld%3ACssParameter+name%3D%22fill-opacity%22%3E1%3C%2Fsld%3ACssParameter%3E%3C%2Fsld%3AFill%3E%3C%2Fsld%3APolygonSymbolizer%3E%3C%2Fsld%3ARule%3E%3C%2Fsld%3AFeatureTypeStyle%3E%3C%2Fsld%3AUserStyle%3E%3C%2Fsld%3ANamedLayer%3E%3C%2Fsld%3AStyledLayerDescriptor%3E%0D%0A',//encodeURIComponent('<?xml version="1.0" encoding="ISO-8859-1"?><sld:StyledLayerDescriptor version="1.0.0" xsi:schemaLocation="http://www.opengis.net/sld StyledLayerDescriptor.xsd" xmlns="http://www.opengis.net/sld" xmlns:sld="http://www.opengis.net/sld" xmlns:ogc="http://www.opengis.net/ogc" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><sld:NamedLayer><sld:Name>Enkelbestemming</sld:Name><sld:UserStyle><sld:Title>gemengd</sld:Title><sld:FeatureTypeStyle><sld:Rule><ogc:Filter><ogc:PropertyIsEqualTo><ogc:PropertyName>bestemmingshoofdgroep</ogc:PropertyName><ogc:Literal>gemengd</ogc:Literal></ogc:PropertyIsEqualTo></ogc:Filter><sld:PolygonSymbolizer><sld:Fill><sld:CssParameter name="fill">#000000</sld:CssParameter><sld:CssParameter name="fill-opacity">1</sld:CssParameter></sld:Fill></sld:PolygonSymbolizer></sld:Rule></sld:FeatureTypeStyle></sld:UserStyle></sld:NamedLayer></sld:StyledLayerDescriptor>'),
FORMAT: layerimage
}
}),
opacity: opacity,
width: mapSize[0],
height: mapSize[1]
});
MapViewer.util.Utility.OLMAP.addLayer(Current_toets_wms);
在这里,MapViewer.util.Utility.OLMAP是添加了图层的Map对象。 编码的SLD在读取时变为:
%253C%253Fxml%2Bversion%253D%25221.0%2522%2Bencoding%253D%2522ISO-8859-1%2522%253F%253E%253Csld%253AStyledLayerDescriptor%2Bversion%253D%25221.0.0%2522%2Bxsi%253AschemaLocation%253D%2522http%253A%252F%252Fwww.opengis.net%252Fsld%2BStyledLayerDescriptor.xsd%2522%2Bxmlns%253D%2522http%253A%252F%252Fwww.opengis.net%252Fsld%2522%2Bxmlns%253Asld%253D%2522http%253A%252F%252Fwww.opengis.net%252Fsld%2522%2Bxmlns%253Aogc%253D%2522http%253A%252F%252Fwww.opengis.net%252Fogc%2522%2Bxmlns%253Axlink%253D%2522http%253A%252F%252Fwww.w3.org%252F1999%252Fxlink%2522%2Bxmlns%253Axsi%253D%2522http%253A%252F%252Fwww.w3.org%252F2001%252FXMLSchema-instance%2522%253E%253CIsDefault%253E1%253C%252FIsDefault%253E%253Csld%253ANamedLayer%253E%253Csld%253AName%253EEnkelbestemming%253C%252Fsld%253AName%253E%253Csld%253AUserStyle%253E%253Csld%253ATitle%253Egemengd%253C%252Fsld%253ATitle%253E%253Csld%253AFeatureTypeStyle%253E%253Csld%253ARule%253E%253Cogc%253AFilter%253E%253Cogc%253APropertyIsEqualTo%253E%253Cogc%253APropertyName%253Ebestemmingshoofdgroep%253C%252Fogc%253APropertyName%253E%253Cogc%253ALiteral%253Egemengd%253C%252Fogc%253ALiteral%253E%253C%252Fogc%253APropertyIsEqualTo%253E%253C%252Fogc%253AFilter%253E%253Csld%253APolygonSymbolizer%253E%253Csld%253AFill%253E%253Csld%253ACssParameter%2Bname%253D%2522fill%2522%253E%2523000000%253C%252Fsld%253ACssParameter%253E%253Csld%253ACssParameter%2Bname%253D%2522fill-opacity%2522%253E1%253C%252Fsld%253ACssParameter%253E%253C%252Fsld%253AFill%253E%253C%252Fsld%253APolygonSymbolizer%253E%253C%252Fsld%253ARule%253E%253C%252Fsld%253AFeatureTypeStyle%253E%253C%252Fsld%253AUserStyle%253E%253C%252Fsld%253ANamedLayer%253E%253C%252Fsld%253AStyledLayerDescriptor%253E%250D%250A
我已经注意了与SLD中提到的图层名称相同的名称。
请帮助,如何保护使用javascript修改SLD。