| const PlotEventType = { | const PlotEventType = { | ||||
| DRAW_START: 'drawStart', | DRAW_START: 'drawStart', | ||||
| DRAW_ANCHOR: 'drawAnchor', | |||||
| DRAW_MOVING: 'drawMoving', | DRAW_MOVING: 'drawMoving', | ||||
| DRAW_STOP: 'drawStop', | DRAW_STOP: 'drawStop', | ||||
| EDIT_START: 'editStart', | EDIT_START: 'editStart', | ||||
| EDIT_STOP: 'editEnd', | EDIT_STOP: 'editEnd', | ||||
| ADD_ANCHOR: 'addAnchor', | |||||
| CREATE_ANCHOR: 'createAnchor', | |||||
| ANCHOR_MOVING: 'anchorMoving', | ANCHOR_MOVING: 'anchorMoving', | ||||
| EDIT_ANCHOR_STOP: 'editAnchorStop', | EDIT_ANCHOR_STOP: 'editAnchorStop', | ||||
| CLEAR_ANCHOR: 'clearAnchor' | CLEAR_ANCHOR: 'clearAnchor' |
| return false | return false | ||||
| } | } | ||||
| if (!this._floatingAnchor) { | if (!this._floatingAnchor) { | ||||
| this._floatingAnchor = this._onAddAnchor({ position }) | |||||
| this._floatingAnchor = this._onCreateAnchor({ position }) | |||||
| } | } | ||||
| this._plotEvent.fire(PlotEventType.ADD_ANCHOR, position) | |||||
| this._plotEvent.fire(PlotEventType.DRAW_ANCHOR, position) | |||||
| } | } | ||||
| /** | /** | ||||
| * @returns {*} | * @returns {*} | ||||
| * @private | * @private | ||||
| */ | */ | ||||
| _onAddAnchor({ position, isCenter = false }) { | |||||
| _onCreateAnchor({ position, isCenter = false }) { | |||||
| this._anchorLayer.entities.add({ | this._anchorLayer.entities.add({ | ||||
| position: position, | position: position, | ||||
| billboard: { | billboard: { | ||||
| this._viewer.on(MouseEventType.CLICK, this._onClick, this) | this._viewer.on(MouseEventType.CLICK, this._onClick, this) | ||||
| this._viewer.on(MouseEventType.MOUSE_MOVE, this._onMouseMove, this) | this._viewer.on(MouseEventType.MOUSE_MOVE, this._onMouseMove, this) | ||||
| this._viewer.on(MouseEventType.RIGHT_CLICK, this._onRightClick, this) | this._viewer.on(MouseEventType.RIGHT_CLICK, this._onRightClick, this) | ||||
| this.on(PlotEventType.ADD_ANCHOR, this._onAddAnchor, this) | |||||
| this.on(PlotEventType.CREATE_ANCHOR, this._onCreateAnchor, this) | |||||
| this.on(PlotEventType.CLEAR_ANCHOR, this._onClearAnchor, this) | this.on(PlotEventType.CLEAR_ANCHOR, this._onClearAnchor, this) | ||||
| } | } | ||||
| this._viewer.off(MouseEventType.CLICK, this._onClick, this) | this._viewer.off(MouseEventType.CLICK, this._onClick, this) | ||||
| this._viewer.off(MouseEventType.MOUSE_MOVE, this._onMouseMove, this) | this._viewer.off(MouseEventType.MOUSE_MOVE, this._onMouseMove, this) | ||||
| this._viewer.off(MouseEventType.RIGHT_CLICK, this._onRightClick, this) | this._viewer.off(MouseEventType.RIGHT_CLICK, this._onRightClick, this) | ||||
| this.off(PlotEventType.ADD_ANCHOR, this._onAddAnchor, this) | |||||
| this.off(PlotEventType.CREATE_ANCHOR, this._onCreateAnchor, this) | |||||
| this.off(PlotEventType.CLEAR_ANCHOR, this._onClearAnchor, this) | this.off(PlotEventType.CLEAR_ANCHOR, this._onClearAnchor, this) | ||||
| } | } | ||||
| * @param isMid | * @param isMid | ||||
| * @private | * @private | ||||
| */ | */ | ||||
| _onAddAnchor({ position, index, isCenter = false, isMid = false }) { | |||||
| _onCreateAnchor({ position, index, isCenter = false, isMid = false }) { | |||||
| let image = isMid | let image = isMid | ||||
| ? this._options.icon_midAnchor | ? this._options.icon_midAnchor | ||||
| : isCenter | : isCenter | ||||
| this._viewer.on(MouseEventType.CLICK, this._onClick, this) | this._viewer.on(MouseEventType.CLICK, this._onClick, this) | ||||
| this._viewer.on(MouseEventType.MOUSE_MOVE, this._onMouseMove, this) | this._viewer.on(MouseEventType.MOUSE_MOVE, this._onMouseMove, this) | ||||
| this._viewer.on(MouseEventType.RIGHT_CLICK, this._onRightClick, this) | this._viewer.on(MouseEventType.RIGHT_CLICK, this._onRightClick, this) | ||||
| this.on(PlotEventType.ADD_ANCHOR, this._onAddAnchor, this) | |||||
| this.on(PlotEventType.CREATE_ANCHOR, this._onCreateAnchor, this) | |||||
| this.on(PlotEventType.CLEAR_ANCHOR, this._onClearAnchor, this) | this.on(PlotEventType.CLEAR_ANCHOR, this._onClearAnchor, this) | ||||
| } | } | ||||
| this._viewer.off(MouseEventType.CLICK, this._onClick, this) | this._viewer.off(MouseEventType.CLICK, this._onClick, this) | ||||
| this._viewer.off(MouseEventType.MOUSE_MOVE, this._onMouseMove, this) | this._viewer.off(MouseEventType.MOUSE_MOVE, this._onMouseMove, this) | ||||
| this._viewer.off(MouseEventType.RIGHT_CLICK, this._onRightClick, this) | this._viewer.off(MouseEventType.RIGHT_CLICK, this._onRightClick, this) | ||||
| this.off(PlotEventType.ADD_ANCHOR, this._onAddAnchor, this) | |||||
| this.off(PlotEventType.CREATE_ANCHOR, this._onCreateAnchor, this) | |||||
| this.off(PlotEventType.CLEAR_ANCHOR, this._onClearAnchor, this) | this.off(PlotEventType.CLEAR_ANCHOR, this._onClearAnchor, this) | ||||
| } | } | ||||