From 00a8251d01513d6390ea414db45cebd0e25019e4 Mon Sep 17 00:00:00 2001 From: hu de yi Date: Tue, 19 Nov 2024 14:04:26 +0800 Subject: [PATCH] fetch support custom fetchOptions --- src/tileget.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/tileget.js b/src/tileget.js index 0134665..a9153f7 100644 --- a/src/tileget.js +++ b/src/tileget.js @@ -31,10 +31,11 @@ function fetchTile(url, headers = {}, options) { if (image) { copyImageBitMap(image); } else { - fetch(url, { + const fetchOptions = options.fetchOptions || { headers, referrer: options.referrer - }).then(res => res.blob()).then(blob => createImageBitmap(blob)).then(image => { + }; + fetch(url, fetchOptions).then(res => res.blob()).then(blob => createImageBitmap(blob)).then(image => { tileCache.add(url, image); copyImageBitMap(image); }).catch(error => {