I tried openlayers 8 and ran into a problem. When using the imageloadfunction, I get the following exception: DOMException: The source image cannot be decoded. The same code works for me in all previous versions of openlayers, so I downgraded to version 7.5.2
this.imageLayer = new ImageLayer({
source: new ImageWMS({
url: lay.geoUrlWms,
//url: environment.serverUrl + '/wms/getMap?url=' + encoded + '&uuid=' + lay.uuid,
imageLoadFunction: function (tile: Image, src) {
var client = new XMLHttpRequest();
client.responseType = 'blob';
const encoded = encodeURIComponent(src);
client.open('GET', environment.serverUrl + '/wms/getMap?url=' + encoded + '&uuid=' + lay.uuid);
headers.forEach((value, key) => {
client.setRequestHeader(key, value);
});
client.onload = function () {
const image = tile.getImage() as HTMLImageElement;
image.src = URL.createObjectURL(client.response);
};
client.send();
},
params: {
'LAYERS': lay.layerName,
'TILED': true,
// 'CQL_FILTER': cqlAll
},
serverType: 'geoserver'
}),
visible: true,
});
I try everything :). Expected to solve my problem.