Skip to content

Commit b8a13d9

Browse files
committedJan 15, 2025
fix(Style): Don't draw stroke when width is 0
1 parent 21b0900 commit b8a13d9

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed
 

‎src/Core/Style.js

+6-5
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ function defineStyleProperty(style, category, parameter, userValue, defaultValue
162162
const dataValue = style.context.featureStyle?.[category]?.[parameter];
163163
if (dataValue != undefined) { return readExpression(dataValue, style.context); }
164164
if (defaultValue instanceof Function) {
165-
return defaultValue(style.context.properties, style.context);
165+
return defaultValue(style.context.properties, style.context) ?? defaultValue;
166166
}
167167
return defaultValue;
168168
},
@@ -808,7 +808,8 @@ class Style {
808808
style.stroke.color = color;
809809
style.stroke.opacity = opacity;
810810
style.stroke.width = 1.0;
811-
style.stroke.dasharray = [];
811+
} else {
812+
style.stroke.width = 0.0;
812813
}
813814
} else if (layer.type === 'line') {
814815
const prepare = readVectorProperty(layer.paint['line-color'], { type: 'color' });
@@ -942,7 +943,7 @@ class Style {
942943
*/
943944
applyToCanvasPolygon(txtrCtx, polygon, invCtxScale, canBeFilled) {
944945
// draw line or edge of polygon
945-
if (this.stroke) {
946+
if (this.stroke.width > 0) {
946947
// TO DO add possibility of using a pattern (https://github.com/iTowns/itowns/issues/2210)
947948
this._applyStrokeToPolygon(txtrCtx, invCtxScale, polygon);
948949
}
@@ -958,11 +959,11 @@ class Style {
958959
if (txtrCtx.strokeStyle !== this.stroke.color) {
959960
txtrCtx.strokeStyle = this.stroke.color;
960961
}
961-
const width = (this.stroke.width || 2.0) * invCtxScale;
962+
const width = this.stroke.width * invCtxScale;
962963
if (txtrCtx.lineWidth !== width) {
963964
txtrCtx.lineWidth = width;
964965
}
965-
const alpha = this.stroke.opacity == undefined ? 1.0 : this.stroke.opacity;
966+
const alpha = this.stroke.opacity;
966967
if (alpha !== txtrCtx.globalAlpha && typeof alpha == 'number') {
967968
txtrCtx.globalAlpha = alpha;
968969
}

0 commit comments

Comments
 (0)
Please sign in to comment.