From 16cad06e57d155a8d96a2b2476fead2492a201b2 Mon Sep 17 00:00:00 2001 From: ahocevar Date: Sun, 6 May 2018 16:05:46 +0200 Subject: [PATCH] Fix skipping of texts with background --- src/ol/render/canvas/TextReplay.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/ol/render/canvas/TextReplay.js b/src/ol/render/canvas/TextReplay.js index 8bbc27251b..de70ceaf3c 100644 --- a/src/ol/render/canvas/TextReplay.js +++ b/src/ol/render/canvas/TextReplay.js @@ -258,14 +258,18 @@ CanvasTextReplay.prototype.drawText = function(geometry, feature) { default: } end = this.appendFlatCoordinates(flatCoordinates, 0, end, stride, false, false); - this.beginGeometry(geometry, feature); if (textState.backgroundFill || textState.backgroundStroke) { this.setFillStrokeStyle(textState.backgroundFill, textState.backgroundStroke); - this.updateFillStyle(this.state, this.createFill, geometry); - this.hitDetectionInstructions.push(this.createFill(this.state, geometry)); - this.updateStrokeStyle(this.state, this.applyStroke); - this.hitDetectionInstructions.push(this.createStroke(this.state)); + if (textState.backgroundFill) { + this.updateFillStyle(this.state, this.createFill, geometry); + this.hitDetectionInstructions.push(this.createFill(this.state, geometry)); + } + if (textState.backgroundStroke) { + this.updateStrokeStyle(this.state, this.applyStroke); + this.hitDetectionInstructions.push(this.createStroke(this.state)); + } } + this.beginGeometry(geometry, feature); this.drawTextImage_(label, begin, end); this.endGeometry(geometry, feature); }