Merge pull request #7750 from schmidtk/canvas-polygon-replay
Don't assume fill for canvas polygon hit detection.
This commit is contained in:
@@ -61,9 +61,9 @@ CanvasPolygonReplay.prototype.drawFlatCoordinatess_ = function(flatCoordinates,
|
|||||||
}
|
}
|
||||||
offset = end;
|
offset = end;
|
||||||
}
|
}
|
||||||
this.hitDetectionInstructions.push(fillInstruction);
|
|
||||||
if (fill) {
|
if (fill) {
|
||||||
this.instructions.push(fillInstruction);
|
this.instructions.push(fillInstruction);
|
||||||
|
this.hitDetectionInstructions.push(fillInstruction);
|
||||||
}
|
}
|
||||||
if (stroke) {
|
if (stroke) {
|
||||||
this.instructions.push(strokeInstruction);
|
this.instructions.push(strokeInstruction);
|
||||||
@@ -85,11 +85,12 @@ CanvasPolygonReplay.prototype.drawCircle = function(circleGeometry, feature) {
|
|||||||
}
|
}
|
||||||
this.setFillStrokeStyles_(circleGeometry);
|
this.setFillStrokeStyles_(circleGeometry);
|
||||||
this.beginGeometry(circleGeometry, feature);
|
this.beginGeometry(circleGeometry, feature);
|
||||||
// always fill the circle for hit detection
|
if (state.fillStyle !== undefined) {
|
||||||
this.hitDetectionInstructions.push([
|
this.hitDetectionInstructions.push([
|
||||||
CanvasInstruction.SET_FILL_STYLE,
|
CanvasInstruction.SET_FILL_STYLE,
|
||||||
asString(defaultFillStyle)
|
asString(defaultFillStyle)
|
||||||
]);
|
]);
|
||||||
|
}
|
||||||
if (state.strokeStyle !== undefined) {
|
if (state.strokeStyle !== undefined) {
|
||||||
this.hitDetectionInstructions.push([
|
this.hitDetectionInstructions.push([
|
||||||
CanvasInstruction.SET_STROKE_STYLE,
|
CanvasInstruction.SET_STROKE_STYLE,
|
||||||
@@ -122,13 +123,19 @@ CanvasPolygonReplay.prototype.drawCircle = function(circleGeometry, feature) {
|
|||||||
*/
|
*/
|
||||||
CanvasPolygonReplay.prototype.drawPolygon = function(polygonGeometry, feature) {
|
CanvasPolygonReplay.prototype.drawPolygon = function(polygonGeometry, feature) {
|
||||||
const state = this.state;
|
const state = this.state;
|
||||||
|
const fillStyle = state.fillStyle;
|
||||||
|
const strokeStyle = state.strokeStyle;
|
||||||
|
if (fillStyle === undefined && strokeStyle === undefined) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
this.setFillStrokeStyles_(polygonGeometry);
|
this.setFillStrokeStyles_(polygonGeometry);
|
||||||
this.beginGeometry(polygonGeometry, feature);
|
this.beginGeometry(polygonGeometry, feature);
|
||||||
// always fill the polygon for hit detection
|
if (state.fillStyle !== undefined) {
|
||||||
this.hitDetectionInstructions.push([
|
this.hitDetectionInstructions.push([
|
||||||
CanvasInstruction.SET_FILL_STYLE,
|
CanvasInstruction.SET_FILL_STYLE,
|
||||||
asString(defaultFillStyle)]
|
asString(defaultFillStyle)
|
||||||
);
|
]);
|
||||||
|
}
|
||||||
if (state.strokeStyle !== undefined) {
|
if (state.strokeStyle !== undefined) {
|
||||||
this.hitDetectionInstructions.push([
|
this.hitDetectionInstructions.push([
|
||||||
CanvasInstruction.SET_STROKE_STYLE,
|
CanvasInstruction.SET_STROKE_STYLE,
|
||||||
@@ -156,11 +163,12 @@ CanvasPolygonReplay.prototype.drawMultiPolygon = function(multiPolygonGeometry,
|
|||||||
}
|
}
|
||||||
this.setFillStrokeStyles_(multiPolygonGeometry);
|
this.setFillStrokeStyles_(multiPolygonGeometry);
|
||||||
this.beginGeometry(multiPolygonGeometry, feature);
|
this.beginGeometry(multiPolygonGeometry, feature);
|
||||||
// always fill the multi-polygon for hit detection
|
if (state.fillStyle !== undefined) {
|
||||||
this.hitDetectionInstructions.push([
|
this.hitDetectionInstructions.push([
|
||||||
CanvasInstruction.SET_FILL_STYLE,
|
CanvasInstruction.SET_FILL_STYLE,
|
||||||
asString(defaultFillStyle)
|
asString(defaultFillStyle)
|
||||||
]);
|
]);
|
||||||
|
}
|
||||||
if (state.strokeStyle !== undefined) {
|
if (state.strokeStyle !== undefined) {
|
||||||
this.hitDetectionInstructions.push([
|
this.hitDetectionInstructions.push([
|
||||||
CanvasInstruction.SET_STROKE_STYLE,
|
CanvasInstruction.SET_STROKE_STYLE,
|
||||||
|
|||||||
Reference in New Issue
Block a user