From f46302b20191c720c8ff9467fdfcf62f87c24b7b Mon Sep 17 00:00:00 2001
From: 张含笑 <zhx18749296735@163.com>
Date: Fri, 13 Jun 2025 15:56:59 +0800
Subject: [PATCH] feat:地图修改样式
---
src/views/dataCenter/components/dataCenterMap.vue | 91 ++++++++++++++++++---------------------------
1 files changed, 36 insertions(+), 55 deletions(-)
diff --git a/src/views/dataCenter/components/dataCenterMap.vue b/src/views/dataCenter/components/dataCenterMap.vue
index 0d80134..2936f99 100644
--- a/src/views/dataCenter/components/dataCenterMap.vue
+++ b/src/views/dataCenter/components/dataCenterMap.vue
@@ -31,20 +31,7 @@
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 => {
@@ -55,7 +42,7 @@
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;
};
@@ -118,7 +105,6 @@
}
currentClickEntity = clickedEntities[0];
- console.log(currentClickEntity);
// 恢复所有点的默认图标
restoreAllIcons();
@@ -126,6 +112,7 @@
// 设置当前点击点为激活状态
if (currentClickEntity.billboard) {
currentClickEntity.billboard.image = activeIcon;
+ currentClickEntity.billboard.scale = 1 // 可选缩放效果
activeEntity.value = currentClickEntity;
}
@@ -164,7 +151,7 @@
// 添加新实体
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),
@@ -202,42 +189,6 @@
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;
@@ -270,6 +221,19 @@
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);
@@ -277,8 +241,6 @@
try {
const res = await getMapInfoAPI(ids);
dataPointList.value = res.data.data || [];
- console.log('dataPointList.value', dataPointList.value);
-
// 确保地图已初始化后再渲染
if (isMapInitialized.value && viewer) {
renderDataPoint(dataPointList.value);
@@ -287,7 +249,26 @@
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 => {
--
Gitblit v1.9.3