From 85ddd2446e3eecd567222e912607554aeac7e3ce Mon Sep 17 00:00:00 2001 From: Andreas Hocevar Date: Tue, 24 Jun 2014 11:18:56 +0200 Subject: [PATCH 1/2] Add endGeometry after hit detection stroke and fill --- src/ol/render/canvas/canvasreplay.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ol/render/canvas/canvasreplay.js b/src/ol/render/canvas/canvasreplay.js index ae2d385f93..96295e9d14 100644 --- a/src/ol/render/canvas/canvasreplay.js +++ b/src/ol/render/canvas/canvasreplay.js @@ -1269,7 +1269,6 @@ ol.render.canvas.PolygonReplay.prototype.drawCircleGeometry = var circleInstruction = [ol.render.canvas.Instruction.CIRCLE]; this.instructions.push(beginPathInstruction, circleInstruction); this.hitDetectionInstructions.push(beginPathInstruction, circleInstruction); - this.endGeometry(circleGeometry, data); var fillInstruction = [ol.render.canvas.Instruction.FILL]; this.hitDetectionInstructions.push(fillInstruction); if (goog.isDef(state.fillStyle)) { @@ -1281,6 +1280,7 @@ ol.render.canvas.PolygonReplay.prototype.drawCircleGeometry = this.instructions.push(strokeInstruction); this.hitDetectionInstructions.push(strokeInstruction); } + this.endGeometry(circleGeometry, data); }; From 2c6b22f55ce26b1c01f251197ea278bd3b239845 Mon Sep 17 00:00:00 2001 From: Frederic Junod Date: Tue, 24 Jun 2014 12:25:21 +0200 Subject: [PATCH 2/2] Use the right coordinates when drawing circles --- src/ol/render/canvas/canvasreplay.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/ol/render/canvas/canvasreplay.js b/src/ol/render/canvas/canvasreplay.js index 96295e9d14..1285071ff4 100644 --- a/src/ol/render/canvas/canvasreplay.js +++ b/src/ol/render/canvas/canvasreplay.js @@ -258,6 +258,8 @@ ol.render.canvas.Replay.prototype.replay_ = function( ++i; break; case ol.render.canvas.Instruction.CIRCLE: + goog.asserts.assert(goog.isNumber(instruction[1])); + d = /** @type {number} */ (instruction[1]); var x1 = pixelCoordinates[d]; var y1 = pixelCoordinates[d + 1]; var x2 = pixelCoordinates[d + 2]; @@ -266,7 +268,6 @@ ol.render.canvas.Replay.prototype.replay_ = function( var dy = y2 - y1; var r = Math.sqrt(dx * dx + dy * dy); context.arc(x1, y1, r, 0, 2 * Math.PI, true); - d += 4; ++i; break; case ol.render.canvas.Instruction.CLOSE_PATH: @@ -1263,10 +1264,11 @@ ol.render.canvas.PolygonReplay.prototype.drawCircleGeometry = } var flatCoordinates = circleGeometry.getFlatCoordinates(); var stride = circleGeometry.getStride(); + var myBegin = this.coordinates.length; this.appendFlatCoordinates( flatCoordinates, 0, flatCoordinates.length, stride, false); var beginPathInstruction = [ol.render.canvas.Instruction.BEGIN_PATH]; - var circleInstruction = [ol.render.canvas.Instruction.CIRCLE]; + var circleInstruction = [ol.render.canvas.Instruction.CIRCLE, myBegin]; this.instructions.push(beginPathInstruction, circleInstruction); this.hitDetectionInstructions.push(beginPathInstruction, circleInstruction); var fillInstruction = [ol.render.canvas.Instruction.FILL];