From 9991d7398b2e88164b9270f820c68289e6aa41f7 Mon Sep 17 00:00:00 2001 From: Matthias Mohr Date: Mon, 2 Oct 2023 22:54:48 +0200 Subject: [PATCH] Fix thumbnail issues --- src/add.js | 2 +- src/utils/bbox-to-bounds.js | 11 ++++++++++- src/utils/image-overlay.js | 2 +- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/add.js b/src/add.js index 5eb35fc..ea7d2de 100644 --- a/src/add.js +++ b/src/add.js @@ -192,7 +192,7 @@ export async function addThumbnail(thumbnails, layerGroup, options) { const layer = await imageOverlay(url, bounds, options.crossOrigin); if (layer === null) { log(1, "image layer is null", url); - return addThumbnail(thumbnails, layerGroup, options); // Retry with the remaining thumbnails + return await addThumbnail(thumbnails, layerGroup, options); // Retry with the remaining thumbnails } addLayer(layer, layerGroup, asset); return await new Promise(resolve => { diff --git a/src/utils/bbox-to-bounds.js b/src/utils/bbox-to-bounds.js index 1061426..ddfd537 100644 --- a/src/utils/bbox-to-bounds.js +++ b/src/utils/bbox-to-bounds.js @@ -5,7 +5,16 @@ * @returns */ export default function bboxToLatLngBounds(bbox) { - const [xmin, ymin, xmax, ymax] = bbox; + let xmin, ymin, xmax, ymax, _; + if (bbox.length === 6) { + [xmin, ymin, _, xmax, ymax, _] = bbox; + } + else if (bbox.length === 4) { + [xmin, ymin, xmax, ymax] = bbox; + } + else { + return null; + } const southWest = [ymin, xmin]; const northEast = [ymax, xmax]; return L.latLngBounds(southWest, northEast); diff --git a/src/utils/image-overlay.js b/src/utils/image-overlay.js index f5a1187..84c265c 100644 --- a/src/utils/image-overlay.js +++ b/src/utils/image-overlay.js @@ -14,7 +14,7 @@ export default async function imageOverlay(url, bounds, crossOrigin, options) { } catch { return null; } - const lyr = L.imageOverlay(url, bounds, options); + const lyr = L.imageOverlay(img, bounds, options); return lyr; } catch { return null;