| | |
| | | :terrain="true" |
| | | :layer-mode="4" |
| | | :boundary="false" |
| | | :zoom-to-boundary="dialogMode === 'add'" |
| | | /> |
| | | </div> |
| | | |
| | |
| | | const formRef = ref(null) // 表单实例 |
| | | const formData = ref(initForm()) // 表单数据 |
| | | const visible = defineModel() // 弹框显隐 |
| | | const dialogMode = ref('add') // 弹框模式 |
| | | const dialogMode = ref('') // 弹框模式 |
| | | const submitting = ref(false) // 提交中 |
| | | const deviceOptions = ref([]) |
| | | const dialogReadonly = computed(() => dialogMode.value === 'view') |
| | |
| | | updateRangeCircle(longitude, latitude, formData.value.effectiveRangeKm) |
| | | } |
| | | |
| | | function flyToRange(longitude, latitude, range) { |
| | | if (!viewer || longitude == null || latitude == null) return |
| | | const rangeMeters = Number(range) |
| | | if (Number.isFinite(rangeMeters) && rangeMeters > 0) { |
| | | const center = Cesium.Cartesian3.fromDegrees(longitude, latitude) |
| | | const radius = Math.max(rangeMeters, 1000) |
| | | const sphere = new Cesium.BoundingSphere(center, radius) |
| | | |
| | | console.log(viewer, longitude, latitude, radius) |
| | | |
| | | |
| | | viewer.camera.flyToBoundingSphere(sphere, { |
| | | duration: 0, |
| | | offset: new Cesium.HeadingPitchRange(viewer.camera.heading, Cesium.Math.toRadians(-90), radius * 1.8), |
| | | }) |
| | | return |
| | | } |
| | | viewer.camera.flyTo({ |
| | | destination: Cesium.Cartesian3.fromDegrees(longitude, latitude, 2000), |
| | | orientation: { |
| | | heading: viewer.camera.heading, |
| | | pitch: Cesium.Math.toRadians(-65), |
| | | roll: 0, |
| | | }, |
| | | duration: 0, |
| | | }) |
| | | } |
| | | |
| | | function parseDeployLocation(value) { |
| | | if (!value) return null |
| | | const [longitude, latitude] = value.split(',').map(item => Number(item.trim())) |
| | |
| | | await nextTick() |
| | | initMap() |
| | | if (dialogMode.value === 'add') { |
| | | mapRef.value?.zoomToAdminBoundary?.() |
| | | |
| | | await loadDeviceOptions() |
| | | formData.value = initForm() |
| | | return |
| | |
| | | const parsed = parseDeployLocation(location) |
| | | if (parsed) { |
| | | setMapPoint(parsed.longitude, parsed.latitude) |
| | | viewer.flyTo(redPointEntity, { duration: 0 }) |
| | | |
| | | flyToRange(parsed.longitude, parsed.latitude, formData.value.effectiveRangeKm) |
| | | } |
| | | } |
| | | } |