1
this.drawInteraction = new ol.interaction.Draw({
features: this.sourceFeatures,
type: 'Polygon',
geometryFunction: (coords, geom) => this.onDrawGeometryFunction(coords, geom)
});
private onDrawGeometryFunction(coords, geom): void {
if (!geom) {
geom = new ol.geom.Polygon(null);
}
if (coords[0].length !== this.coords_length) {
//if intersects undo last point
if (this.intersectionsExistInPolygon(coords[0])) {
this.drawInteraction.removeLastPoint();
return geom;
}
this.coords_length = coords[0].length;
}
geom.setCoordinates(coords);
return geom;
}
我能夠識別交點,直到我點擊起點完成繪製(通過繪製線連接)。有沒有辦法在發生之前聽完抽獎(但不是「抽獎」)?通過移除相交的最後一點來保持繪圖模式有效。如果座標相交,ol3重繪繪製交互模式