Always fill polygons for hit detection

This commit is contained in:
Éric Lemoine
2013-12-11 16:14:25 +01:00
parent ac2a3cd1e8
commit 829381fd43

View File

@@ -858,10 +858,10 @@ ol.render.canvas.PolygonReplay.prototype.drawFlatCoordinatess_ =
} }
// FIXME is it quicker to fill and stroke each polygon individually, // FIXME is it quicker to fill and stroke each polygon individually,
// FIXME or all polygons together? // FIXME or all polygons together?
var fillInstruction = [ol.render.canvas.Instruction.FILL];
this.hitDetectionInstructions.push(fillInstruction);
if (goog.isDef(state.fillStyle)) { if (goog.isDef(state.fillStyle)) {
var fillInstruction = [ol.render.canvas.Instruction.FILL];
this.instructions.push(fillInstruction); this.instructions.push(fillInstruction);
this.hitDetectionInstructions.push(fillInstruction);
} }
if (goog.isDef(state.strokeStyle)) { if (goog.isDef(state.strokeStyle)) {
goog.asserts.assert(goog.isDef(state.lineWidth)); goog.asserts.assert(goog.isDef(state.lineWidth));
@@ -891,10 +891,10 @@ ol.render.canvas.PolygonReplay.prototype.drawPolygonGeometry =
ol.extent.extend(this.extent_, polygonGeometry.getExtent()); ol.extent.extend(this.extent_, polygonGeometry.getExtent());
this.setFillStrokeStyles_(); this.setFillStrokeStyles_();
this.beginGeometry(polygonGeometry); this.beginGeometry(polygonGeometry);
if (goog.isDef(state.fillStyle)) { // always fill the polygon for hit detection
this.hitDetectionInstructions.push( this.hitDetectionInstructions.push(
[ol.render.canvas.Instruction.SET_FILL_STYLE, state.fillStyle]); [ol.render.canvas.Instruction.SET_FILL_STYLE,
} ol.color.asString(ol.render.canvas.defaultFillStyle)]);
if (goog.isDef(state.strokeStyle)) { if (goog.isDef(state.strokeStyle)) {
this.hitDetectionInstructions.push( this.hitDetectionInstructions.push(
[ol.render.canvas.Instruction.SET_STROKE_STYLE, [ol.render.canvas.Instruction.SET_STROKE_STYLE,
@@ -927,10 +927,10 @@ ol.render.canvas.PolygonReplay.prototype.drawMultiPolygonGeometry =
ol.extent.extend(this.extent_, multiPolygonGeometry.getExtent()); ol.extent.extend(this.extent_, multiPolygonGeometry.getExtent());
this.setFillStrokeStyles_(); this.setFillStrokeStyles_();
this.beginGeometry(multiPolygonGeometry); this.beginGeometry(multiPolygonGeometry);
if (goog.isDef(state.fillStyle)) { // always fill the multi-polygon for hit detection
this.hitDetectionInstructions.push( this.hitDetectionInstructions.push(
[ol.render.canvas.Instruction.SET_FILL_STYLE, state.fillStyle]); [ol.render.canvas.Instruction.SET_FILL_STYLE,
} ol.color.asString(ol.render.canvas.defaultFillStyle)]);
if (goog.isDef(state.strokeStyle)) { if (goog.isDef(state.strokeStyle)) {
this.hitDetectionInstructions.push( this.hitDetectionInstructions.push(
[ol.render.canvas.Instruction.SET_STROKE_STYLE, [ol.render.canvas.Instruction.SET_STROKE_STYLE,