Skip to content

Commit

Permalink
fix: allow scale to be a GeoStylerFunction
Browse files Browse the repository at this point in the history
  • Loading branch information
Kai Volland committed Dec 5, 2023
1 parent 113ef5e commit 73d2271
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions src/MapboxStyleParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -432,9 +432,20 @@ export class MapboxStyleParser implements StyleParser<Omit<MbStyle, 'sources'>>

// mabpox icon-size scales the image and does not define its size
if (layout?.['icon-size'] && image) {
const scale = mb2gsExpression<number>(layout['icon-size']) as number;
// mulitply the mb icon-size with the width of the sprite to get the scale
symbolizer.size = scale * (image.size[0] as number);
const scale = mb2gsExpression<number>(layout['icon-size']);

// multiply the mb icon-size with the width of the sprite to get the scale
if (isGeoStylerFunction(scale)) {
symbolizer.size = {
name: 'mul',
args: [
scale,
image.size[0]
]
};
} else if (scale) {
symbolizer.size = scale * (image.size[0] as number);
}

// Add icon-size to metadata
set(
Expand Down

0 comments on commit 73d2271

Please sign in to comment.