|
|
@@ -2,7 +2,7 @@
|
|
|
<div ref="mapContainer" class="map-container"></div>
|
|
|
<div class="map-container cad-container" id="map2dContainer"></div>
|
|
|
<div v-if="!isTopLevel" class="map-reset-btn">
|
|
|
- <Button type="primary" @click="revertStack">返回上级</Button>
|
|
|
+ <Button :loading="mapLoading" type="primary" @click="revertStack">返回上级</Button>
|
|
|
</div>
|
|
|
<div
|
|
|
id="map-copyright"
|
|
|
@@ -25,7 +25,7 @@
|
|
|
<script lang="ts" setup>
|
|
|
import 'vjmap/dist/vjmap.min.css';
|
|
|
import { ref, onMounted, onUnmounted, computed } from 'vue';
|
|
|
- import { Button, message } from 'ant-design-vue';
|
|
|
+ import { Button } from 'ant-design-vue';
|
|
|
import { useAppStore } from '/@/store/modules/app';
|
|
|
// import { useRoute } from 'vue-router';
|
|
|
import vjmap from 'vjmap';
|
|
|
@@ -38,9 +38,11 @@
|
|
|
import { generatePopupContent, generateSimplePopup } from './hooks/popup';
|
|
|
import { initMap2d, renderGoafMarkers } from '/@/views/system/cadFile/app';
|
|
|
import { getGoafList } from '/@/views/system/cadFile/cad.api';
|
|
|
+ // import { useGlobSetting } from '/@/hooks/setting';
|
|
|
|
|
|
const appStore = useAppStore();
|
|
|
const mineStore = useMineDepartmentStore();
|
|
|
+ // const globSetting = useGlobSetting();
|
|
|
appStore.setSimpleMapParams({ deptId: mineStore.getRootId, isLeaf: mineStore.getRoot?.isLeaf });
|
|
|
// const route = useRoute();
|
|
|
|
|
|
@@ -104,13 +106,18 @@
|
|
|
// 设置 hover 鼠标指针样式和状态更新
|
|
|
circles.hoverPointer();
|
|
|
circles.hoverFeatureState();
|
|
|
- circles.hoverPopup((f) => {
|
|
|
- if (f.properties.isLeaf) {
|
|
|
- return generatePopupContent(f.properties);
|
|
|
- } else {
|
|
|
- return generateSimplePopup(f.properties);
|
|
|
+ circles.hoverPopup(
|
|
|
+ (f) => {
|
|
|
+ if (f.properties.isLeaf) {
|
|
|
+ return generatePopupContent(f.properties);
|
|
|
+ } else {
|
|
|
+ return generateSimplePopup(f.properties);
|
|
|
+ }
|
|
|
+ },
|
|
|
+ {
|
|
|
+ maxWidth: '500px',
|
|
|
}
|
|
|
- });
|
|
|
+ );
|
|
|
|
|
|
const symbols = new vjmap.Symbol({
|
|
|
layerId: SYMBOL_LAYER_ID,
|
|
|
@@ -180,44 +187,50 @@
|
|
|
return map;
|
|
|
}
|
|
|
|
|
|
+ const mapLoading = ref(false);
|
|
|
let cadOpened: boolean;
|
|
|
/** 切换CAD地图和瓦片地图的显示,通过重新初始化进行切换,避免出现动画异常和多个DOM节点 */
|
|
|
async function toggleCADMap(visiable: boolean) {
|
|
|
if (cadOpened === visiable) return;
|
|
|
|
|
|
cadOpened = visiable;
|
|
|
+ mapLoading.value = true;
|
|
|
map?.destory();
|
|
|
- if (visiable) {
|
|
|
- const hide = message.loading('CAD图加载中...', 0);
|
|
|
- const [m, res] = await Promise.all([
|
|
|
- initMap2d(mapContainer.value!, {
|
|
|
- // fileUrl: node.url
|
|
|
- style: { backcolor: 0xe6f3ff },
|
|
|
- }),
|
|
|
- getGoafList({
|
|
|
- mineCode: mineStore.getRoot?.fax,
|
|
|
- deptId: mineStore.getRootId,
|
|
|
- }),
|
|
|
- ]);
|
|
|
- hide();
|
|
|
- map = m;
|
|
|
-
|
|
|
- renderGoafMarkers(res); // 渲染标记
|
|
|
- } else {
|
|
|
- // const hide = message.loading('地图加载中...', 0);
|
|
|
- const [m, res] = await Promise.all([
|
|
|
- initMap(mapContainer.value!),
|
|
|
- getGeoJSON({
|
|
|
- deptId: mineStore.getRootId,
|
|
|
- pageSize: 9999,
|
|
|
- }),
|
|
|
- ]);
|
|
|
- const [geojson, __, markers] = res;
|
|
|
- // hide();
|
|
|
- map = m;
|
|
|
-
|
|
|
- initMapGeoJSON(map, geojson);
|
|
|
- initMapMarker(map, markers);
|
|
|
+
|
|
|
+ try {
|
|
|
+ if (visiable) {
|
|
|
+ const [m, res] = await Promise.all([
|
|
|
+ initMap2d(mapContainer.value!, {
|
|
|
+ // fileUrl: node.url
|
|
|
+ // fileUrl: `${globSetting.apiUrl}/sys/common/static/webfile/hongliulin_default.dwg`,
|
|
|
+ style: { backcolor: 0xe6f3ff },
|
|
|
+ }),
|
|
|
+ getGoafList({
|
|
|
+ mineCode: mineStore.getRoot?.fax,
|
|
|
+ deptId: mineStore.getRootId,
|
|
|
+ }),
|
|
|
+ ]);
|
|
|
+ map = m;
|
|
|
+
|
|
|
+ renderGoafMarkers(res); // 渲染标记
|
|
|
+ } else {
|
|
|
+ // const hide = message.loading('地图加载中...', 0);
|
|
|
+ const [m, res] = await Promise.all([
|
|
|
+ initMap(mapContainer.value!),
|
|
|
+ getGeoJSON({
|
|
|
+ deptId: mineStore.getRootId,
|
|
|
+ pageSize: 9999,
|
|
|
+ }),
|
|
|
+ ]);
|
|
|
+ const [geojson, __, markers] = res;
|
|
|
+ // hide();
|
|
|
+ map = m;
|
|
|
+
|
|
|
+ initMapGeoJSON(map, geojson);
|
|
|
+ initMapMarker(map, markers);
|
|
|
+ }
|
|
|
+ } finally {
|
|
|
+ mapLoading.value = false;
|
|
|
}
|
|
|
}
|
|
|
|