Skip to content

Commit

Permalink
fix: use width and multiply directly
Browse files Browse the repository at this point in the history
  • Loading branch information
Kai Volland committed Dec 5, 2023
1 parent ebc9434 commit 113ef5e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 12 deletions.
5 changes: 1 addition & 4 deletions data/styles/icon_simpleicon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,7 @@ const iconSimpleIcon: Style = {
position: [0, 0],
size: [12, 12]
},
size: {
name: 'mul',
args: [2, 12]
}
size: 24
}]
}],
metadata: {
Expand Down
10 changes: 2 additions & 8 deletions src/MapboxStyleParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -433,14 +433,8 @@ 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;
const widthHeightAverage = ((image.size[0] as number) + (image.size[1] as number)) / 2;
symbolizer.size = {
name: 'mul',
args: [
scale,
widthHeightAverage
]
};
// mulitply the mb icon-size with the width of the sprite to get the scale
symbolizer.size = scale * (image.size[0] as number);

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

0 comments on commit 113ef5e

Please sign in to comment.