2026-03-27 15:52:43 +08:00
|
|
|
|
<template>
|
2026-06-03 15:03:31 +08:00
|
|
|
|
<div class="gis-view">
|
|
|
|
|
|
<div id="mapContainer" />
|
|
|
|
|
|
<div ref="popupRef" class="map-popup-container" style="display: none"></div>
|
|
|
|
|
|
<!-- - 1. 切换菜单的时候图层没有切换 ,是因为接口的原因,现在没有接口
|
2026-06-01 08:42:06 +08:00
|
|
|
|
2. 切换菜单的时候图例现在是不对的,默认选中的数据他们没有做处理
|
2026-06-30 08:41:54 +08:00
|
|
|
|
-->
|
2026-03-31 14:17:30 +08:00
|
|
|
|
<!-- 地图图例 -->
|
2026-06-03 15:03:31 +08:00
|
|
|
|
<MapLegend />
|
2026-06-01 08:42:06 +08:00
|
|
|
|
|
2026-03-31 14:17:30 +08:00
|
|
|
|
<!-- 地图筛选器 -->
|
2026-06-01 08:42:06 +08:00
|
|
|
|
<MapFilter v-if="showMapFilter" :map="mapClass" />
|
|
|
|
|
|
|
2026-03-31 14:17:30 +08:00
|
|
|
|
<!-- 地图控制器 -->
|
2026-04-22 17:53:20 +08:00
|
|
|
|
<MapController :map="mapClass" :onClick="handleMapController" />
|
2026-06-01 08:42:06 +08:00
|
|
|
|
|
2026-03-31 14:17:30 +08:00
|
|
|
|
<!-- 基础图层切换器 -->
|
2026-04-22 17:53:20 +08:00
|
|
|
|
<BaseLayerSwitcher :map="mapClass" />
|
2026-06-03 15:03:31 +08:00
|
|
|
|
<!-- 梯级弹框 -->
|
|
|
|
|
|
<TjLayerModal v-model:open="tjModalVisible" />
|
2026-03-31 14:17:30 +08:00
|
|
|
|
</div>
|
2026-03-27 15:52:43 +08:00
|
|
|
|
</template>
|
2026-03-31 14:17:30 +08:00
|
|
|
|
<script setup lang="ts">
|
2026-06-01 08:42:06 +08:00
|
|
|
|
import { ref, onMounted, watch, onUnmounted, computed } from 'vue';
|
|
|
|
|
|
import MapLegend from '@/components/mapLegend/index.vue';
|
|
|
|
|
|
import MapFilter from '@/components/mapFilter/index.vue';
|
|
|
|
|
|
import MapController from '@/components/mapController/index.vue';
|
|
|
|
|
|
import BaseLayerSwitcher from '@/components/BaseLayerSwitcher/index.vue';
|
2026-06-03 15:03:31 +08:00
|
|
|
|
import TjLayerModal from './TjLayerModal.vue';
|
2026-06-01 08:42:06 +08:00
|
|
|
|
import { useRoute } from 'vue-router';
|
2026-06-03 15:03:31 +08:00
|
|
|
|
import { useMapOrchestrator } from '@/modules/map/application/map-orchestrator';
|
2026-06-01 08:42:06 +08:00
|
|
|
|
import { MapClass } from './map.class';
|
2026-06-03 15:03:31 +08:00
|
|
|
|
import { getQgcRvcd } from '@/api/map';
|
|
|
|
|
|
import { servers } from './mapurlManage';
|
2026-05-11 17:45:09 +08:00
|
|
|
|
|
2026-06-03 15:03:31 +08:00
|
|
|
|
const mapOrchestrator = useMapOrchestrator();
|
2026-06-01 08:42:06 +08:00
|
|
|
|
|
2026-04-22 17:53:20 +08:00
|
|
|
|
const route = useRoute();
|
|
|
|
|
|
const mapClass = MapClass.getInstance();
|
2026-06-01 08:42:06 +08:00
|
|
|
|
const mapIsInited = ref(false);
|
2026-04-22 17:53:20 +08:00
|
|
|
|
const tlyLayerVisible = ref(false);
|
2026-06-03 15:03:31 +08:00
|
|
|
|
const tjModalVisible = ref(false);
|
|
|
|
|
|
const popupRef = ref<HTMLDivElement | null>(null);
|
2026-06-01 08:42:06 +08:00
|
|
|
|
|
2026-06-03 15:03:31 +08:00
|
|
|
|
// 备注:根据当前路由生成页面配置 key,供统一编排器加载页面地图配置。
|
2026-06-01 08:42:06 +08:00
|
|
|
|
const pageKey = computed(() => {
|
|
|
|
|
|
const path = route.path;
|
|
|
|
|
|
const parts = path.split('/');
|
|
|
|
|
|
if (parts.length >= 3) {
|
|
|
|
|
|
return parts[1] + '_' + parts[2];
|
2026-04-22 17:53:20 +08:00
|
|
|
|
}
|
2026-06-01 08:42:06 +08:00
|
|
|
|
return '';
|
|
|
|
|
|
});
|
2026-04-22 17:53:20 +08:00
|
|
|
|
|
2026-06-03 15:03:31 +08:00
|
|
|
|
// 备注:仅根据页面路径控制筛选器显隐,不在组件内承载地图业务逻辑。
|
2026-06-01 08:42:06 +08:00
|
|
|
|
const showMapFilter = computed(() => {
|
|
|
|
|
|
const path = route.path;
|
2026-06-03 15:03:31 +08:00
|
|
|
|
return !path.includes('dianZhanZhuanTi/dianZhanZhuanTi');
|
2026-06-01 08:42:06 +08:00
|
|
|
|
});
|
|
|
|
|
|
|
2026-06-03 15:03:31 +08:00
|
|
|
|
// 备注:仅保留当前菜单类型判断,缩放联动细节由编排器内部处理。
|
2026-06-01 08:42:06 +08:00
|
|
|
|
const isShuiDianKaiFaMenu = computed(() => {
|
2026-06-03 15:03:31 +08:00
|
|
|
|
return route.path.includes('home/shuiDianKaiFaZhuangKuang');
|
2026-06-01 08:42:06 +08:00
|
|
|
|
});
|
|
|
|
|
|
|
2026-06-03 15:03:31 +08:00
|
|
|
|
// 备注:页面只负责触发地图初始化,初始化后的缩放监听和基地监听由编排器接管。
|
2026-04-22 17:53:20 +08:00
|
|
|
|
const init = async () => {
|
2026-06-01 08:42:06 +08:00
|
|
|
|
const container = document.getElementById('mapContainer') as HTMLElement;
|
|
|
|
|
|
if (!container) return;
|
|
|
|
|
|
|
2026-06-03 15:03:31 +08:00
|
|
|
|
await mapOrchestrator.mountView({
|
|
|
|
|
|
container,
|
|
|
|
|
|
popupContainer: popupRef.value,
|
|
|
|
|
|
pageKey: pageKey.value,
|
|
|
|
|
|
getIsHydroMenu: () => isShuiDianKaiFaMenu.value
|
2026-04-22 17:53:20 +08:00
|
|
|
|
});
|
2026-05-15 17:38:03 +08:00
|
|
|
|
|
2026-06-03 15:03:31 +08:00
|
|
|
|
mapIsInited.value = true;
|
2026-05-15 17:38:03 +08:00
|
|
|
|
};
|
2026-06-01 08:42:06 +08:00
|
|
|
|
|
2026-06-03 15:03:31 +08:00
|
|
|
|
// 备注:地图控制器只分发简单视图切换命令,避免在页面入口堆叠复杂业务逻辑。
|
2026-05-15 17:38:03 +08:00
|
|
|
|
const handleMapController = async (e: any, mapType: any) => {
|
2026-04-22 17:53:20 +08:00
|
|
|
|
switch (e) {
|
2026-06-01 08:42:06 +08:00
|
|
|
|
case 'dim':
|
2026-05-15 17:38:03 +08:00
|
|
|
|
await mapClass.switchView(mapType);
|
|
|
|
|
|
break;
|
2026-04-22 17:53:20 +08:00
|
|
|
|
case 4: // 梯级流域显示
|
|
|
|
|
|
tlyLayerVisible.value = !tlyLayerVisible.value;
|
|
|
|
|
|
if (tlyLayerVisible.value) {
|
2026-06-03 15:03:31 +08:00
|
|
|
|
tjModalVisible.value = true;
|
|
|
|
|
|
fetchTjData();
|
2026-04-22 17:53:20 +08:00
|
|
|
|
} else {
|
2026-06-03 15:03:31 +08:00
|
|
|
|
tjModalVisible.value = false;
|
|
|
|
|
|
mapClass.hideTertiarybasinLayer(servers.Tertiarybasin);
|
2026-04-22 17:53:20 +08:00
|
|
|
|
}
|
2026-06-01 08:42:06 +08:00
|
|
|
|
break;
|
2026-04-22 17:53:20 +08:00
|
|
|
|
default:
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
};
|
2026-06-03 15:03:31 +08:00
|
|
|
|
const fetchTjData = async () => {
|
|
|
|
|
|
const res = await getQgcRvcd({});
|
|
|
|
|
|
if (res && res.data) {
|
|
|
|
|
|
let datas = [];
|
|
|
|
|
|
for (let i = 0; i < res.data.data.length; i++) {
|
|
|
|
|
|
datas.push(res.data.data[i].rvcd);
|
2026-06-01 08:42:06 +08:00
|
|
|
|
}
|
2026-06-03 15:03:31 +08:00
|
|
|
|
console.log(servers.Tertiarybasin);
|
|
|
|
|
|
mapClass.addTertiarybasinLayer(
|
|
|
|
|
|
servers.Tertiarybasin,
|
|
|
|
|
|
'#4DFFDD',
|
|
|
|
|
|
'#92A0A5',
|
|
|
|
|
|
datas
|
|
|
|
|
|
);
|
2026-06-01 08:42:06 +08:00
|
|
|
|
}
|
2026-06-03 15:03:31 +08:00
|
|
|
|
};
|
2026-06-01 08:42:06 +08:00
|
|
|
|
|
2026-06-03 15:03:31 +08:00
|
|
|
|
// 备注:页面切换后仅触发编排器重载页面,不在组件内继续拼装业务联动。
|
2026-06-01 08:42:06 +08:00
|
|
|
|
watch(
|
|
|
|
|
|
() => pageKey.value,
|
2026-06-03 15:03:31 +08:00
|
|
|
|
async newVal => {
|
2026-06-01 08:42:06 +08:00
|
|
|
|
if (newVal && mapIsInited.value) {
|
2026-06-03 15:03:31 +08:00
|
|
|
|
await mapOrchestrator.handlePageChange(newVal, isShuiDianKaiFaMenu.value);
|
2026-04-22 17:53:20 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
);
|
2026-06-01 08:42:06 +08:00
|
|
|
|
|
2026-04-03 16:04:16 +08:00
|
|
|
|
onMounted(() => {
|
2026-04-22 17:53:20 +08:00
|
|
|
|
init();
|
2026-06-01 08:42:06 +08:00
|
|
|
|
// @ts-ignore
|
2026-04-22 17:53:20 +08:00
|
|
|
|
window.mapClass = mapClass;
|
|
|
|
|
|
});
|
2026-06-01 08:42:06 +08:00
|
|
|
|
|
2026-04-22 17:53:20 +08:00
|
|
|
|
onUnmounted(() => {
|
2026-06-03 15:03:31 +08:00
|
|
|
|
mapOrchestrator.unmountView();
|
2026-04-22 17:53:20 +08:00
|
|
|
|
mapClass.destroy();
|
|
|
|
|
|
});
|
2026-03-31 14:17:30 +08:00
|
|
|
|
</script>
|
2026-03-27 15:52:43 +08:00
|
|
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
|
|
.gis-view {
|
2026-03-31 14:17:30 +08:00
|
|
|
|
width: 100%;
|
|
|
|
|
|
height: 100%;
|
|
|
|
|
|
position: absolute;
|
|
|
|
|
|
visibility: visible;
|
2026-03-27 15:52:43 +08:00
|
|
|
|
}
|
|
|
|
|
|
#mapContainer {
|
2026-03-31 14:17:30 +08:00
|
|
|
|
width: 100%;
|
|
|
|
|
|
height: 100%;
|
2026-04-03 16:04:16 +08:00
|
|
|
|
position: absolute;
|
|
|
|
|
|
background-color: #fff;
|
2026-05-13 08:44:35 +08:00
|
|
|
|
cursor: grab;
|
2026-04-22 17:53:20 +08:00
|
|
|
|
z-index: 1;
|
|
|
|
|
|
}
|
|
|
|
|
|
/* 消除瓦片之间的缝隙和默认边框 */
|
|
|
|
|
|
.leaflet-tile {
|
|
|
|
|
|
border: none !important;
|
|
|
|
|
|
margin: 0 !important;
|
|
|
|
|
|
padding: 0 !important;
|
|
|
|
|
|
image-rendering: -webkit-optimize-contrast;
|
|
|
|
|
|
image-rendering: crisp-edges;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* 确保地图容器背景色与瓦片一致,避免透出底色 */
|
|
|
|
|
|
.leaflet-container {
|
2026-06-01 08:42:06 +08:00
|
|
|
|
background-color: #fff;
|
2026-04-22 17:53:20 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* 如果使用 Canvas 模式,确保 Canvas 没有边框 */
|
|
|
|
|
|
.leaflet-pane canvas {
|
|
|
|
|
|
border: none;
|
2026-03-27 15:52:43 +08:00
|
|
|
|
}
|
2026-05-15 17:38:03 +08:00
|
|
|
|
|
|
|
|
|
|
.map-popup-container {
|
|
|
|
|
|
z-index: 1000;
|
2026-06-01 08:42:06 +08:00
|
|
|
|
pointer-events: auto;
|
2026-05-15 17:38:03 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.custom-popup {
|
|
|
|
|
|
padding: 10px;
|
|
|
|
|
|
}
|
|
|
|
|
|
.custom-popup h4 {
|
|
|
|
|
|
margin: 0 0 5px 0;
|
|
|
|
|
|
color: #333;
|
|
|
|
|
|
}
|
|
|
|
|
|
.custom-popup p {
|
|
|
|
|
|
margin: 2px 0;
|
|
|
|
|
|
font-size: 12px;
|
|
|
|
|
|
color: #666;
|
|
|
|
|
|
}
|
2026-03-27 15:52:43 +08:00
|
|
|
|
</style>
|