| | |
| | | import * as turf from '@turf/turf' |
| | | import { ElMessage } from 'element-plus' |
| | | import { flyVisual, getPointPositionsHeight } from './index' |
| | | import { MapTooltip } from './MapTooltip' |
| | | |
| | | /** |
| | | * 多边形绘制与编辑工具类 |
| | |
| | | this.delPoint = this.delPoint.bind(this) |
| | | // 外部订阅者 |
| | | this.listeners = [] |
| | | // 绘制提示 tooltip |
| | | this.drawingTooltip = null |
| | | } |
| | | |
| | | // 实体命名常量 |
| | |
| | | const cartesian = this.viewer.scene.pickPosition(movement.endPosition) |
| | | if (!cartesian) return |
| | | |
| | | // 更新绘制提示 tooltip 位置 |
| | | if (this.drawingMode && this.drawingTooltip) { |
| | | this.drawingTooltip.move(movement.endPosition) |
| | | } |
| | | |
| | | // 编辑模式下,拖拽点实时更新 |
| | | if (this.editingMode && this.draggedEntity?.customData) { |
| | | this.draggedEntity.position = cartesian |
| | |
| | | finishDrawing() { |
| | | this.curPolygon.positions.pop() |
| | | |
| | | // 隐藏绘制提示 |
| | | if (this.drawingTooltip) { |
| | | this.drawingTooltip.hide() |
| | | } |
| | | |
| | | if (this.curPolygon.positions.length >= 3) { |
| | | this.drawingMode = false |
| | | this.editingMode = true |
| | |
| | | this.removeMenuPopup() |
| | | this.notify('getPolygonPositions', []) |
| | | this.startDrawing() |
| | | |
| | | // 重新显示绘制提示 |
| | | if (this.drawingTooltip) { |
| | | this.drawingTooltip.show('左键点击绘制,双击结束绘制') |
| | | } |
| | | } |
| | | // 删除图斑 |
| | | delSpot() { |
| | |
| | | this.viewer = viewer |
| | | this.startDrawing() |
| | | |
| | | // 初始化绘制提示 tooltip |
| | | if (!this.drawingTooltip) { |
| | | this.drawingTooltip = new MapTooltip(viewer) |
| | | this.drawingTooltip.show('左键点击绘制,双击结束绘制') |
| | | } |
| | | |
| | | if (!this.handler) { |
| | | this.handler = new Cesium.ScreenSpaceEventHandler(viewer.scene.canvas) |
| | | |
| | |
| | | this.removeEntities() |
| | | this.removeHandler() |
| | | this.enableMapControl() |
| | | |
| | | // 销毁绘制提示 tooltip |
| | | if (this.drawingTooltip) { |
| | | this.drawingTooltip.destroy() |
| | | this.drawingTooltip = null |
| | | } |
| | | } |
| | | } |