Skip to content

Commit

Permalink
Style.setFromVectorTileLayer & sprites -> warn message if sprites is …
Browse files Browse the repository at this point in the history
…needed
  • Loading branch information
ftoromanoff committed Oct 20, 2023
1 parent a32d87f commit 8bc11d4
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions src/Core/Style.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 8bc11d4

Please sign in to comment.