Export with openlayers then reach the layers.js file contained in the layers folder, modify your layer by adding tileLoadFunction: customLoader
and add the customLoader
function at the beginning of the file in which you will have to enter your username and password
function customLoader(tile, src) {
var client = new XMLHttpRequest();
client.open('GET', src);
// Uncomment to pass authentication header
//var user = '';
//var pass = '';
//client.setRequestHeader("Authorization", "Basic " + window.btoa(user + ":" + pass));
client.onload = function() {
tile.getImage().src = src;
};
client.send();
}
var lyr_Outdoors_0 = new ol.layer.Tile({
source: new ol.source.WMTS(({
url: "https://api.mapbox.com/styles/v1/adarshredhill/clyocmzb9004h01pidczp9caf/wmts",
attributions: ' ',
tileLoadFunction: customLoader,
"layer": "clyocmzb9004h01pidczp9caf",
"TILED": "true",
matrixSet: 'EPSG:3857',
format: 'image/png',
projection: projection_Outdoors_0,
tileGrid: new ol.tilegrid.WMTS({
origin: ol.extent.getTopLeft(projectionExtent_Outdoors_0),
resolutions: resolutions_Outdoors_0,
matrixIds: matrixIds_Outdoors_0
}),
style: 'default',
wrapX: true,
"VERSION": "1.0.0",
})),
title: "Outdoors",
opacity: 1.0,
});