From 3fea282f3e7b807a74ccdbea9965b1b82d3863ac Mon Sep 17 00:00:00 2001
From: 罗广辉 <guanghui.luo@foxmail.com>
Date: Sat, 31 Jan 2026 16:50:07 +0800
Subject: [PATCH] feat: 绘制面工具类加个提示
---
packages/utils/map/DrawPolygon.js | 30 ++++++++++++++++++++++++++++++
1 files changed, 30 insertions(+), 0 deletions(-)
diff --git a/packages/utils/map/DrawPolygon.js b/packages/utils/map/DrawPolygon.js
index 80c3518..77ec1e6 100644
--- a/packages/utils/map/DrawPolygon.js
+++ b/packages/utils/map/DrawPolygon.js
@@ -2,6 +2,7 @@
import * as turf from '@turf/turf'
import { ElMessage } from 'element-plus'
import { flyVisual, getPointPositionsHeight } from './index'
+import { MapTooltip } from './MapTooltip'
/**
* 多边形绘制与编辑工具类
@@ -63,6 +64,8 @@
this.delPoint = this.delPoint.bind(this)
// 外部订阅者
this.listeners = []
+ // 绘制提示 tooltip
+ this.drawingTooltip = null
}
// 实体命名常量
@@ -431,6 +434,11 @@
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
@@ -579,6 +587,11 @@
finishDrawing() {
this.curPolygon.positions.pop()
+ // 隐藏绘制提示
+ if (this.drawingTooltip) {
+ this.drawingTooltip.hide()
+ }
+
if (this.curPolygon.positions.length >= 3) {
this.drawingMode = false
this.editingMode = true
@@ -607,6 +620,11 @@
this.removeMenuPopup()
this.notify('getPolygonPositions', [])
this.startDrawing()
+
+ // 重新显示绘制提示
+ if (this.drawingTooltip) {
+ this.drawingTooltip.show('左键点击绘制,双击结束绘制')
+ }
}
// 删除图斑
delSpot() {
@@ -760,6 +778,12 @@
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)
@@ -807,5 +831,11 @@
this.removeEntities()
this.removeHandler()
this.enableMapControl()
+
+ // 销毁绘制提示 tooltip
+ if (this.drawingTooltip) {
+ this.drawingTooltip.destroy()
+ this.drawingTooltip = null
+ }
}
}
--
Gitblit v1.9.3