Skip to content

Commit

Permalink
use texture size if no sprites defined
Browse files Browse the repository at this point in the history
  • Loading branch information
meetar committed May 10, 2018
1 parent 2ee8c38 commit e3f0d17
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/styles/points/points.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,10 +171,12 @@ Object.assign(Points, {
else {
style.size = StyleParser.evalCachedPointSizeProperty(draw.size, sprite_info, context);
if (style.size == null) {
log({ level: 'warn', once: true }, `Layer '${draw.layers[draw.layers.length-1]}': ` +
`'size' includes % and/or ratio-based scaling (${JSON.stringify(draw.size.value)}); ` +
`these can only applied to sprites, but no sprite was specified, skipping features in layer`);
return;
// the StyleParser couldn't evaluate a sprite size - this means no sprite was defined,
// use the texture size
let tex = Texture.textures[style.texture];
let factor = (draw.size.value.indexOf('%') > -1 ? parseFloat(draw.size.value) : 1.0) / 100.0;
style.size = [(tex.width * factor), (tex.height * factor)];

}
else if (typeof style.size === 'number') {
style.size = [style.size, style.size]; // convert 1d size to 2d
Expand Down

0 comments on commit e3f0d17

Please sign in to comment.