明树Git Lab

Commit fd84dd6b authored by chenron's avatar chenron

地图修改

parent d773c3f5
...@@ -263,9 +263,20 @@ const updateMarkers = (selectName) => { ...@@ -263,9 +263,20 @@ const updateMarkers = (selectName) => {
handleAddMarket(selectName); handleAddMarket(selectName);
}; };
// 重置地图到初始状态
const resetMap = () => {
if (map) {
map.setZoom(4);
map.setCenter([100.808299, 35.791787]);
const mapSize = map.getSize();
mapSize.width < 780 ? map.setZoom(3.5) : map.setZoom(4);
}
};
// 暴露方法给父组件 // 暴露方法给父组件
defineExpose({ defineExpose({
updateMarkers, updateMarkers,
resetMap,
}); });
onMounted(() => { onMounted(() => {
handleInitMap(); handleInitMap();
...@@ -276,9 +287,6 @@ onMounted(() => { ...@@ -276,9 +287,6 @@ onMounted(() => {
.tourism { .tourism {
width: 100%; width: 100%;
.vh(height, 600); .vh(height, 600);
// display: flex;
// justify-content: center;
// align-items: center;
} }
.custom-content-marker { .custom-content-marker {
position: relative; position: relative;
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
<img src="@/assets/images/建设.png" /> <img src="@/assets/images/建设.png" />
</div> --> </div> -->
<div class="construct-left-map"> <div class="construct-left-map">
<Map /> <Map ref="mapRef" />
</div> </div>
</div> </div>
<div class="construct-right"> <div class="construct-right">
...@@ -51,6 +51,7 @@ import { ...@@ -51,6 +51,7 @@ import {
onUnmounted, onUnmounted,
shallowReactive, shallowReactive,
defineOptions, defineOptions,
onActivated
} from "vue"; } from "vue";
import CircleProgress from "./CircleProgress.vue"; import CircleProgress from "./CircleProgress.vue";
...@@ -58,6 +59,9 @@ import CircleProgress from "./CircleProgress.vue"; ...@@ -58,6 +59,9 @@ import CircleProgress from "./CircleProgress.vue";
defineOptions({ defineOptions({
name: "Construct", name: "Construct",
}); });
// 地图组件引用
const mapRef = ref(null);
// 使用shallowReactive减少深层响应式开销 // 使用shallowReactive减少深层响应式开销
const projectList = shallowReactive([ const projectList = shallowReactive([
{ title: "总个数", value: "10", unit: "个" }, { title: "总个数", value: "10", unit: "个" },
...@@ -75,6 +79,18 @@ const recycleList = shallowReactive([ ...@@ -75,6 +79,18 @@ const recycleList = shallowReactive([
{ title: "2025年完成投资", value: "*", unit: "亿元" }, { title: "2025年完成投资", value: "*", unit: "亿元" },
{ title: "完成率", value: "*", unit: "" }, { title: "完成率", value: "*", unit: "" },
]); ]);
// 组件被激活时重置地图
onActivated(() => {
if (mapRef.value && mapRef.value.resetMap) {
mapRef.value.resetMap();
}
// 确保显示建设阶段的标记
if (mapRef.value && mapRef.value.updateMarkers) {
mapRef.value.updateMarkers("建设");
}
});
</script> </script>
<style scoped lang="less"> <style scoped lang="less">
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
<img src="@/assets/images/建设.png" /> <img src="@/assets/images/建设.png" />
</div> --> </div> -->
<div class="construct-left-map"> <div class="construct-left-map">
<Map /> <Map ref="mapRef" />
</div> </div>
</div> </div>
<div class="construct-right"> <div class="construct-right">
...@@ -44,12 +44,16 @@ import { ...@@ -44,12 +44,16 @@ import {
onMounted, onMounted,
onUnmounted, onUnmounted,
defineOptions, defineOptions,
onActivated
} from "vue"; } from "vue";
// 定义组件名称,用于keep-alive缓存 // 定义组件名称,用于keep-alive缓存
defineOptions({ defineOptions({
name: "Operation", name: "Operation",
}); });
// 地图组件引用
const mapRef = ref(null);
// 使用shallowReactive减少深层响应式开销 // 使用shallowReactive减少深层响应式开销
const projectList = shallowReactive([ const projectList = shallowReactive([
{ title: "总个数", value: "2", unit: "个" }, { title: "总个数", value: "2", unit: "个" },
...@@ -100,6 +104,18 @@ const completeList = shallowReactive([ ...@@ -100,6 +104,18 @@ const completeList = shallowReactive([
cumulativeValue: "*", cumulativeValue: "*",
}, },
]); ]);
// 组件被激活时重置地图
onActivated(() => {
if (mapRef.value && mapRef.value.resetMap) {
mapRef.value.resetMap();
}
// 确保显示运营阶段的标记
if (mapRef.value && mapRef.value.updateMarkers) {
mapRef.value.updateMarkers("运营");
}
});
</script> </script>
<style scoped lang="less"> <style scoped lang="less">
......
...@@ -16,6 +16,7 @@ import { ...@@ -16,6 +16,7 @@ import {
computed, computed,
shallowRef, shallowRef,
defineOptions, defineOptions,
onActivated
} from "vue"; } from "vue";
// 定义组件名称,用于keep-alive缓存 // 定义组件名称,用于keep-alive缓存
...@@ -68,6 +69,13 @@ watch( ...@@ -68,6 +69,13 @@ watch(
}, },
{ immediate: true } { immediate: true }
); );
// 组件被激活时重置地图
onActivated(() => {
if (mapRef.value && mapRef.value.resetMap) {
mapRef.value.resetMap();
}
});
</script> </script>
<style scoped lang="less"> <style scoped lang="less">
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
<img src="@/assets/images/建设.png" /> <img src="@/assets/images/建设.png" />
</div> --> </div> -->
<div class="construct-left-map"> <div class="construct-left-map">
<Map /> <Map ref="mapRef" />
</div> </div>
</div> </div>
<div class="construct-right"> <div class="construct-right">
...@@ -44,12 +44,16 @@ import { ...@@ -44,12 +44,16 @@ import {
onMounted, onMounted,
onUnmounted, onUnmounted,
defineOptions, defineOptions,
onActivated
} from "vue"; } from "vue";
// 定义组件名称,用于keep-alive缓存 // 定义组件名称,用于keep-alive缓存
defineOptions({ defineOptions({
name: "Operation", name: "TrialOperations",
}); });
// 地图组件引用
const mapRef = ref(null);
// 使用shallowReactive减少深层响应式开销 // 使用shallowReactive减少深层响应式开销
const projectList = shallowReactive([ const projectList = shallowReactive([
{ title: "总个数", value: "9", unit: "个" }, { title: "总个数", value: "9", unit: "个" },
...@@ -115,6 +119,18 @@ const completeList = shallowReactive([ ...@@ -115,6 +119,18 @@ const completeList = shallowReactive([
cumulativeValue: "-7.94", cumulativeValue: "-7.94",
}, },
]); ]);
// 组件被激活时重置地图
onActivated(() => {
if (mapRef.value && mapRef.value.resetMap) {
mapRef.value.resetMap();
}
// 确保显示试运营阶段的标记
if (mapRef.value && mapRef.value.updateMarkers) {
mapRef.value.updateMarkers("试运营");
}
});
</script> </script>
<style scoped lang="less"> <style scoped lang="less">
......
...@@ -53,15 +53,15 @@ ...@@ -53,15 +53,15 @@
>{{ item.name }} >{{ item.name }}
</span> </span>
</div> </div>
<!-- <keep-alive include="ProjectApproval,Construct,Operation,TrialOperations"> --> <keep-alive include="ProjectApproval,Construct,Operation,TrialOperations">
<ProjectApproval <ProjectApproval
:currentName="selectedContentName" :currentName="selectedContentName"
v-if="selectedContentBtn === 1 || selectedContentBtn === 6" v-if="selectedContentBtn === 1 || selectedContentBtn === 6"
/> />
<Construct v-else-if="selectedContentBtn === 2" /> <Construct v-else-if="selectedContentBtn === 2" />
<Operation v-else-if="selectedContentBtn === 4" /> <Operation v-else-if="selectedContentBtn === 4" />
<TrialOperations v-else-if="selectedContentBtn === 3" /> <TrialOperations v-else-if="selectedContentBtn === 3" />
<!-- </keep-alive> --> </keep-alive>
</div> </div>
<div class="bottom"></div> <div class="bottom"></div>
</div> </div>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment