From 8bc11d40689e7844133af181579e1dbc30f35404 Mon Sep 17 00:00:00 2001 From: ftoromanoff Date: Tue, 17 Oct 2023 15:15:56 +0200 Subject: [PATCH] Style.setFromVectorTileLayer & sprites -> warn message if sprites is needed --- src/Core/Style.js | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/Core/Style.js b/src/Core/Style.js index 5200e8ee25..8fa0cbbc6d 100644 --- a/src/Core/Style.js +++ b/src/Core/Style.js @@ -692,7 +692,10 @@ class Style { const { color, opacity } = rgba2rgb(readVectorProperty(layer.paint['fill-color'] || layer.paint['fill-pattern'], { type: 'color' })); this.fill.color = color; this.fill.opacity = readVectorProperty(layer.paint['fill-opacity']) || opacity; - if (layer.paint['fill-pattern'] && sprites) { + if (layer.paint['fill-pattern']) { + if (!sprites) { + console.warn("argument sprites must not be null when using layer.paint['fill-pattern']"); + } this.fill.pattern = { id: layer.paint['fill-pattern'], source: sprites.source, @@ -760,13 +763,15 @@ class Style { } // additional icon - const icon = readVectorProperty(layer.layout['icon-image']); - if (icon) { - this.icon.id = icon; - this.icon.source = sprites?.source || icon; - if (sprites) { - this.icon.cropValues = sprites[icon]; + const iconImg = readVectorProperty(layer.layout['icon-image']); + if (iconImg) { + if (!sprites) { + console.warn("argument sprites must not be null when using layer.layout['icon-image']"); } + this.icon.id = iconImg; + this.icon.source = sprites.source; + this.icon.cropValues = sprites[iconImg]; + this.icon.size = readVectorProperty(layer.layout['icon-size']) || 1; const { color, opacity } = rgba2rgb(readVectorProperty(layer.paint['icon-color'], { type: 'color' })); this.icon.color = color;