Answered on github.
By default, the image is downloaded as follows: img.src = ' http://example.com/tile.png '; - that is, we set the src attribute of the image to the image URL. In this case, you cannot set the headers for the request.
, source.setTileLoadFunction(customLoader). , "tile image". . ol.ImageTile URL.
. :
function customLoader(tile, src) {
var client = new XMLHttpRequest();
client.open('GET', src);
client.setRequestHeader('foo', 'bar');
client.onload(function() {
var data = 'data:image/png;base64,' + btoa(unescape(encodeURIComponent(this.responseText));
tile.getImage().src = data;
});
client.send();
}