| | |
| | | const isMapInitialized = ref(false); //地图加载 |
| | | const dataPointList = ref([]); |
| | | const activeEntity = ref(null); // 当前激活的点 |
| | | watch( |
| | | () => props.dotData, |
| | | newVal => { |
| | | if (newVal) { |
| | | // console.log(newVal, 999); |
| | | // currentClickEntity = newVal; |
| | | // activeEntity.value = newVal; |
| | | // singleMachineEvent(newVal); |
| | | // // createLabelDom(newVal); |
| | | // console.log('cccc', activeEntity.value); |
| | | } |
| | | }, |
| | | { immediate: true } |
| | | ); |
| | | |
| | | // 获取弹框box |
| | | const detailId = ref(''); |
| | | const createLabelDom = data => { |
| | |
| | | tooltipContainer.style.position = 'absolute'; |
| | | tooltipContainer.style.transform = 'translate(-50%,-125%)'; |
| | | tooltipContainer.style.pointerEvents = 'none'; |
| | | document.querySelector('#dataCenterMap').append(tooltipContainer); |
| | | document.querySelector('#dataCenterMap')?.append(tooltipContainer); |
| | | render(vNode, tooltipContainer); |
| | | return tooltipContainer; |
| | | }; |
| | |
| | | } |
| | | |
| | | currentClickEntity = clickedEntities[0]; |
| | | console.log(currentClickEntity); |
| | | |
| | | // 恢复所有点的默认图标 |
| | | restoreAllIcons(); |
| | |
| | | // 设置当前点击点为激活状态 |
| | | if (currentClickEntity.billboard) { |
| | | currentClickEntity.billboard.image = activeIcon; |
| | | currentClickEntity.billboard.scale = 1 // 可选缩放效果 |
| | | activeEntity.value = currentClickEntity; |
| | | } |
| | | |
| | |
| | | |
| | | // 添加新实体 |
| | | mapList.forEach((item, index) => { |
| | | const entity = viewer.entities.add({ |
| | | const entity = viewer?.entities.add({ |
| | | id: `dataCenter-point-${index}-${Date.now()}`, |
| | | position: Cesium.Cartesian3.fromDegrees( |
| | | Number(item.metadata.shootPosition.lng), |
| | |
| | | dataPointEntities.value.push(entity); |
| | | }); |
| | | }; |
| | | |
| | | const flyToEntity = position => { |
| | | const longitude = Number(position.lng); |
| | | const latitude = Number(position.lat); |
| | | |
| | | console.log(longitude, viewer, 1); |
| | | viewer?.camera.flyTo({ |
| | | destination: Cesium.Cartesian3.fromDegrees(longitude, latitude, 1000), |
| | | duration: 1, |
| | | orientation: { |
| | | heading: Cesium.Math.toRadians(0.0), |
| | | pitch: Cesium.Math.toRadians(-90.0), |
| | | roll: 0.0, |
| | | }, |
| | | }); |
| | | }; |
| | | |
| | | const isViewerReady = ref(false); |
| | | |
| | | /** |
| | | * 初始化标注添加 |
| | | * @param data 数据 |
| | | */ |
| | | const initEntityOrPopup = data => { //地图点在范围内 |
| | | watch( |
| | | () => isViewerReady.value, |
| | | ready => { |
| | | if (ready) { |
| | | flyToEntity(data.metadata.shootPosition); |
| | | labelBoxUpdate(); |
| | | } |
| | | }, |
| | | { deep: true, immediate: true } // 初始化时立即执行 |
| | | ); |
| | | }; |
| | | |
| | | const initMap = () => { |
| | | if (viewer || isMapInitialized.value) return; |
| | | |
| | |
| | | console.error('地图初始化失败:', error); |
| | | } |
| | | }; |
| | | const flyToEntity = position => { |
| | | const longitude = Number(position.lng); |
| | | const latitude = Number(position.lat); |
| | | viewer?.camera.flyTo({ |
| | | destination: Cesium.Cartesian3.fromDegrees(longitude, latitude, 1000), |
| | | duration: 1, |
| | | orientation: { |
| | | heading: Cesium.Math.toRadians(0.0), |
| | | pitch: Cesium.Math.toRadians(-90.0), |
| | | roll: 0.0, |
| | | }, |
| | | }); |
| | | }; |
| | | |
| | | // 地图接口 |
| | | const loading = ref(false); |
| | |
| | | try { |
| | | const res = await getMapInfoAPI(ids); |
| | | dataPointList.value = res.data.data || []; |
| | | console.log('dataPointList.value', dataPointList.value); |
| | | |
| | | // 确保地图已初始化后再渲染 |
| | | if (isMapInitialized.value && viewer) { |
| | | renderDataPoint(dataPointList.value); |
| | |
| | | console.error('获取地图数据失败:', error); |
| | | } |
| | | }; |
| | | const isViewerReady = ref(false); |
| | | |
| | | /** |
| | | * 初始化标注添加 |
| | | * @param data 数据 |
| | | */ |
| | | const initEntityOrPopup = data => { |
| | | //地图点在范围内 |
| | | watch( |
| | | [() => isMapInitialized.value], |
| | | ready => { |
| | | |
| | | if (ready) { |
| | | flyToEntity(data.metadata.shootPosition); |
| | | labelBoxUpdate(); |
| | | } |
| | | }, |
| | | { deep: true, immediate: true } // 初始化时立即执行 |
| | | ); |
| | | }; |
| | | watch( |
| | | () => props.jobId, |
| | | newVal => { |