Thanks for your reply. Would you mind if I ask if L.TileLayer.xhr you used is a plugin you develop youself? I could not find it anywhere. Thanks. My codes are below:
wms_headerPlugin <- htmlDependency("leaflet-wms-header","1.0.8",
src = normalizePath("D:/API/www/leaflet-wms-header/"),
script="index.js")
registerPlugin <- function(map, plugin) {
map$dependencies <- c(map$dependencies, list(plugin))
map
}
leaflet() %>% addTiles() %>%
setView(145.98705368, -36.56692057, 14)%>%
registerPlugin(wms_headerPlugin) %>%
onRender("
function(el, x,data) {
var xhrLayer = new L.TileLayer.wmsHeader(
'https://xxx.com/api/wms',
{
layers: 'xxxx',
service: 'wms',
format: 'image/png',
version: '1.3.0',
TIME: '2020-01-01T00:00:00Z/2021-01-01T00:00:00Z',
crs: 3857,
VARIABLECODES: 'xxx',
EXCEPTIONS: 'xxx',
request: 'xxx',
ORGANISATIONID:xxxx
}
, [
{ header: 'Authorization', value: 'Bearer token'},
{ header: 'content-type', value: 'text/plain'},
],null)
.addTo(this);
}")