| | |
| | | import axios from 'axios' |
| | | import { saveOperationLog } from '@ztzf/apis' |
| | | import { useRoute } from 'vue-router' |
| | | import positionIcon from '@/assets/images/areaManage/positionIcon.png' |
| | | |
| | | const initForm = () => ({ |
| | | address: '', // 位置 |
| | |
| | | let redPointEntity |
| | | let leftClickBound = false |
| | | const labelParams = { |
| | | font: '16px', |
| | | font: '18px', |
| | | fillColor: Cesium.Color.WHITE, // 文字颜色:白色 |
| | | backgroundColor: Cesium.Color.BLACK, //背景颜色 |
| | | backgroundPadding: new Cesium.Cartesian2(5, 5), // 水平/垂直内边距(像素) |
| | |
| | | } |
| | | |
| | | function LeftClickEvent(click) { |
| | | const pos = click.position // Cartesian2 屏幕坐标 |
| | | // 屏幕坐标 -> 椭球面坐标(不考虑地形/模型) |
| | | const cartesian3 = viewer.camera.pickEllipsoid(pos, viewer.scene.globe.ellipsoid) |
| | | if (!cartesian3) { |
| | | return { longitude: 112, latitude: 23 } |
| | | const pos = click.position |
| | | // 优先使用 pickPosition 获取贴地坐标(包含地形高度) |
| | | let cartesian3 = viewer.scene.pickPosition(pos) |
| | | // 如果 pickPosition 失败,回退到 pickEllipsoid |
| | | if (!cartesian3 || !Cesium.defined(cartesian3)) { |
| | | cartesian3 = viewer.camera.pickEllipsoid(pos, viewer.scene.globe.ellipsoid) |
| | | } |
| | | // 椭球面坐标 -> 经纬度 |
| | | if (!cartesian3) return |
| | | const carto = Cesium.Cartographic.fromCartesian(cartesian3) |
| | | const longitude = Cesium.Math.toDegrees(carto.longitude) |
| | | const latitude = Cesium.Math.toDegrees(carto.latitude) |
| | | // 直接更新 formData |
| | | formData.value.longitude = _.round(longitude, 6) |
| | | formData.value.latitude = _.round(latitude, 6) |
| | | getLocationName(longitude, latitude) |
| | |
| | | if (!redPointEntity) { |
| | | redPointEntity = viewer.entities.add({ |
| | | position: Cesium.Cartesian3.fromDegrees(longitude, latitude), |
| | | point: { |
| | | color: Cesium.Color.RED, |
| | | pixelSize: 10, |
| | | billboard: { |
| | | image: positionIcon, |
| | | width: 20, |
| | | height: 20, |
| | | verticalOrigin: Cesium.VerticalOrigin.CENTER, |
| | | heightReference: Cesium.HeightReference.CLAMP_TO_GROUND, |
| | | }, |
| | | label: { |
| | | text: `${longitude.toFixed(6)}, ${latitude.toFixed(6)}`, |
| | | ...labelParams |
| | | ...labelParams, |
| | | }, |
| | | }) |
| | | } else { |
| | |
| | | if (!redPointEntity) { |
| | | redPointEntity = viewer.entities.add({ |
| | | position: Cesium.Cartesian3.fromDegrees(longitude, latitude), |
| | | point: { |
| | | color: Cesium.Color.RED, |
| | | pixelSize: 10, |
| | | billboard: { |
| | | image: positionIcon, |
| | | width: 20, |
| | | height: 20, |
| | | verticalOrigin: Cesium.VerticalOrigin.CENTER, |
| | | heightReference: Cesium.HeightReference.CLAMP_TO_GROUND, |
| | | }, |
| | | label: { |
| | | text: `${longitude.toFixed(6)}, ${latitude.toFixed(6)}`, |
| | | ...labelParams |
| | | ...labelParams, |
| | | }, |
| | | }) |
| | | } else { |