| this._plotEvent.addEventListener(this._completeCallback, this) | this._plotEvent.addEventListener(this._completeCallback, this) | ||||
| } | } | ||||
| /** | |||||
| * | |||||
| * @param type | |||||
| * @param style | |||||
| * @private | |||||
| */ | |||||
| _createDrawWorker(type, style) { | _createDrawWorker(type, style) { | ||||
| switch (type) { | switch (type) { | ||||
| case OverlayType.POINT: | case OverlayType.POINT: | ||||
| } | } | ||||
| } | } | ||||
| /** | |||||
| * | |||||
| * @param overlay | |||||
| * @private | |||||
| */ | |||||
| _createEditWorker(overlay) { | _createEditWorker(overlay) { | ||||
| switch (overlay.type) { | switch (overlay.type) { | ||||
| case OverlayType.POINT: | case OverlayType.POINT: | ||||
| } | } | ||||
| } | } | ||||
| draw(type, callback, style) { | |||||
| /** | |||||
| * | |||||
| * @param type | |||||
| * @param callback | |||||
| * @param style | |||||
| * @param clampToGround | |||||
| * @returns {Plot} | |||||
| */ | |||||
| draw(type, callback, style, clampToGround) { | |||||
| this._state = 'draw' | this._state = 'draw' | ||||
| if (this._drawWorker) { | if (this._drawWorker) { | ||||
| this._drawWorker.unbindEvent() | this._drawWorker.unbindEvent() | ||||
| this._viewer.tooltip.enable = true | this._viewer.tooltip.enable = true | ||||
| this._bindEvent(callback) | this._bindEvent(callback) | ||||
| this._createDrawWorker(type, style) | this._createDrawWorker(type, style) | ||||
| this._drawWorker && this._drawWorker.start(this) | |||||
| this._drawWorker && | |||||
| this._drawWorker.start(this, clampToGround ?? this._options.clampToGround) | |||||
| return this | |||||
| } | } | ||||
| edit(overlay, callback) { | |||||
| /** | |||||
| * | |||||
| * @param overlay | |||||
| * @param callback | |||||
| * @param clampToGround | |||||
| * @returns {Plot} | |||||
| */ | |||||
| edit(overlay, callback, clampToGround) { | |||||
| this._state = 'edit' | this._state = 'edit' | ||||
| if (this._editWorker) { | if (this._editWorker) { | ||||
| this._editWorker.unbindEvent() | this._editWorker.unbindEvent() | ||||
| this._viewer.tooltip.enable = true | this._viewer.tooltip.enable = true | ||||
| this._bindEvent(callback) | this._bindEvent(callback) | ||||
| this._createEditWorker(overlay) | this._createEditWorker(overlay) | ||||
| this._editWorker && this._editWorker.start(this) | |||||
| this._editWorker && | |||||
| this._editWorker.start(this, clampToGround ?? this._options.clampToGround) | |||||
| return this | |||||
| } | } | ||||
| /** | |||||
| * | |||||
| * @returns {Plot} | |||||
| */ | |||||
| destroy() { | destroy() { | ||||
| this._plotEvent.removeEventListener(this._completeCallback, this) | this._plotEvent.removeEventListener(this._completeCallback, this) | ||||
| this._viewer.dataSources.remove(this._overlayLayer) | this._viewer.dataSources.remove(this._overlayLayer) | ||||
| this._viewer.dataSources.remove(this._anchorLayer) | this._viewer.dataSources.remove(this._anchorLayer) | ||||
| this._viewer = undefined | this._viewer = undefined | ||||
| this._plotEvent = undefined | this._plotEvent = undefined | ||||
| return this | |||||
| } | } | ||||
| } | } | ||||
| this._viewer.off(MouseEventType.RIGHT_CLICK, this._onRightClick, this) | this._viewer.off(MouseEventType.RIGHT_CLICK, this._onRightClick, this) | ||||
| } | } | ||||
| /** | |||||
| * | |||||
| * @param position | |||||
| * @param isCenter | |||||
| * @returns {*} | |||||
| */ | |||||
| createAnchor(position, isCenter = false) { | createAnchor(position, isCenter = false) { | ||||
| return this._layer.add({ | return this._layer.add({ | ||||
| position: position, | position: position, | ||||
| }) | }) | ||||
| } | } | ||||
| start(plot) { | |||||
| /** | |||||
| * | |||||
| * @param plot | |||||
| * @param clampToGround | |||||
| */ | |||||
| start(plot, clampToGround) { | |||||
| this._viewer = plot.viewer | this._viewer = plot.viewer | ||||
| this._tooltip = plot.viewer.tooltip | this._tooltip = plot.viewer.tooltip | ||||
| this._layer = plot.overlayLayer | this._layer = plot.overlayLayer | ||||
| this._plotEvent = plot.plotEvent | this._plotEvent = plot.plotEvent | ||||
| this._options = plot.options | this._options = plot.options | ||||
| this._clampToGround = plot.options.clampToGround ?? true | |||||
| this._clampToGround = clampToGround | |||||
| this._mountEntity() | this._mountEntity() | ||||
| this.bindEvent() | this.bindEvent() | ||||
| } | } |
| this._viewer.off(MouseEventType.RIGHT_CLICK, this._onRightClick, this) | this._viewer.off(MouseEventType.RIGHT_CLICK, this._onRightClick, this) | ||||
| } | } | ||||
| /** | |||||
| * | |||||
| * @param position | |||||
| * @param index | |||||
| * @param isMid | |||||
| * @param isCenter | |||||
| */ | |||||
| createAnchor(position, index, isMid = false, isCenter = false) { | createAnchor(position, index, isMid = false, isCenter = false) { | ||||
| let image = isMid | let image = isMid | ||||
| ? this._options.icon_midAnchor | ? this._options.icon_midAnchor | ||||
| this._anchors.push(anchor) | this._anchors.push(anchor) | ||||
| } | } | ||||
| /** | |||||
| * | |||||
| * @param p1 | |||||
| * @param p2 | |||||
| * @returns {Cartesian3} | |||||
| */ | |||||
| computeMidPosition(p1, p2) { | computeMidPosition(p1, p2) { | ||||
| let c1 = Cesium.Ellipsoid.WGS84.cartesianToCartographic(p1) | let c1 = Cesium.Ellipsoid.WGS84.cartesianToCartographic(p1) | ||||
| let c2 = Cesium.Ellipsoid.WGS84.cartesianToCartographic(p2) | let c2 = Cesium.Ellipsoid.WGS84.cartesianToCartographic(p2) | ||||
| return Cesium.Ellipsoid.WGS84.cartographicToCartesian(cm) | return Cesium.Ellipsoid.WGS84.cartographicToCartesian(cm) | ||||
| } | } | ||||
| start(plot) { | |||||
| /** | |||||
| * | |||||
| * @param plot | |||||
| * @param clampToGround | |||||
| */ | |||||
| start(plot, clampToGround) { | |||||
| this._viewer = plot.viewer | this._viewer = plot.viewer | ||||
| this._tooltip = plot.viewer.tooltip | this._tooltip = plot.viewer.tooltip | ||||
| this._layer = plot.overlayLayer | this._layer = plot.overlayLayer | ||||
| this._anchorLayer = plot.anchorLayer | this._anchorLayer = plot.anchorLayer | ||||
| this._plotEvent = plot.plotEvent | this._plotEvent = plot.plotEvent | ||||
| this._options = plot.options | this._options = plot.options | ||||
| this._clampToGround = plot.options.clampToGround ?? true | |||||
| this._clampToGround = clampToGround | |||||
| this._mountEntity() | this._mountEntity() | ||||
| this._mountAnchor() | this._mountAnchor() | ||||
| this.bindEvent() | this.bindEvent() |