| @@ -160,8 +160,11 @@ class Plot { | |||
| if (this._currentWorker) { | |||
| this._currentWorker.stop() | |||
| } | |||
| let maxAnchorSize = style?.maxAnchorSize || 999 | |||
| style && delete style['maxAnchorSize'] | |||
| this._currentWorker = this._createDrawWorker(type, style)?.start(this, { | |||
| ...this._options, | |||
| maxAnchorSize: maxAnchorSize, | |||
| onDrawStop: callback, | |||
| clampToModel: clampToModel ?? this._options.clampToModel | |||
| }) | |||
| @@ -61,8 +61,13 @@ class DrawPolyline extends Draw { | |||
| * @private | |||
| */ | |||
| _onDrawAnchor(position) { | |||
| let len = this._positions.length | |||
| this._positions.push(position) | |||
| this.drawTool.fire(PlotEventType.CREATE_ANCHOR, { position }) | |||
| if (len >= this._options.maxAnchorSize) { | |||
| this._positions.pop() | |||
| this.drawTool.fire(PlotEventType.DRAW_STOP) | |||
| } | |||
| } | |||
| } | |||
| @@ -14,7 +14,8 @@ const DEF_OPTS = { | |||
| icon_center: IMG_CIRCLE_YELLOW, | |||
| icon_anchor: IMG_CIRCLE_RED, | |||
| icon_size: [12, 12], | |||
| clampToModel: false | |||
| clampToModel: false, | |||
| maxAnchorSize: 999 | |||
| } | |||
| class DrawTool { | |||