吉安感知网项目-前端
shuishen
5 days ago 6e88705bd5b443a259b24c17c8a299765d059d96
applications/drone-command/src/utils/cesium/shapeTools/draw/DrawPolygonTool.js
@@ -91,6 +91,9 @@
   }
   start() {
      if (!this.tooltip) {
         this.tooltip = new MapTooltip(this.viewer)
      }
      this.dataSource = new Cesium.CustomDataSource('draw-polygon')
      this.viewer.dataSources.add(this.dataSource)
      this.handler = new Cesium.ScreenSpaceEventHandler(this.viewer.scene.canvas)
@@ -137,12 +140,18 @@
   handleMouseMove(movement) {
      if (!this.isDrawing) return
      const tipText = this.getTipText()
      if (!this.tooltip?.isVisible) {
         this.tooltip?.show(tipText, movement.endPosition)
      } else {
         this.tooltip?.show(tipText)
         this.tooltip?.move(movement.endPosition)
      }
      if (this.positions.length === 0) return
      const position = this.getPositionFromScreen(movement.endPosition)
      if (!position) return
      this.lastMousePosition = position
      this.floatPosition = position
      this.tooltip.show(this.getTipText(), movement.endPosition)
   }
   getTipText() {
@@ -277,7 +286,7 @@
      this.floatPosition = null
      this.isIntersecting = false
      this.notify('getPolygonPositions', this.positions)
      this.tooltip.hide()
      this.tooltip?.hide()
      this.clearPreviewEntities()
   }
@@ -304,7 +313,8 @@
   getPositionFromScreen(screenPosition) {
      const scene = this.viewer.scene
      const cartesian = scene.pickPosition(screenPosition)
      const ray = scene.camera.getPickRay(screenPosition)
      const cartesian = ray ? scene.globe.pick(ray, scene) : null
      if (cartesian) return cartesian
      return scene.camera.pickEllipsoid(screenPosition, scene.globe.ellipsoid)
   }