From ff1e2e08c6d5dbfaf68ecf2437d200f57eadd845 Mon Sep 17 00:00:00 2001 From: helloxujingliang <3225043@qq.com> Date: Tue, 26 Nov 2024 09:49:19 +0800 Subject: [PATCH] merge --- src/views/sys/exception/Converge/index.vue | 91 ++++++++++++---------- 1 file changed, 51 insertions(+), 40 deletions(-) diff --git a/src/views/sys/exception/Converge/index.vue b/src/views/sys/exception/Converge/index.vue index efc9751e..267ecd9a 100644 --- a/src/views/sys/exception/Converge/index.vue +++ b/src/views/sys/exception/Converge/index.vue @@ -164,6 +164,53 @@ }); }; + // load map info + + async function loadMapInfo(){ + try{ + await getNetworkType().then(res=>{ + if(res){ + networkType.value = "WAN"; + }else{ + networkType.value = "LAN"; + } + }); + }catch(e){ + networkType.value = "WAN"; + }finally{ + map = initMap(); + map.on('load', () => { + //挂载mapbox-gl-utils + U.init(map); + mp = new MP(map); + + // 添加地形数据 + map.addSource('mapbox-dem', { + type: 'raster-dem', + tiles: [VITE_GLOB_API_URL_VAR.value + '/mapbox_terrain/{z}/{x}/{y}.png'], + tileSize: 256, + maxzoom: 13, + minzoom: 10, + }); + // map.setTerrain({ source: 'mapbox-dem', exaggeration: 1 }); + + // 设置2D地图 + map.easeTo({ pitch: 0, bearing: 0, duration: 1000 }); + map.dragRotate.disable(); // 禁用拖动旋转 + map.pitchWithRotate = false; // 禁用旋转时俯仰变化 + mapAngle.value = '2D'; + + handlerCheckUserOrgs(); + // handlerLoadMaskLayer(); + getMaskData(); + handlerDealStreet(); + handlerDealCountry(); + + // 视频监控 + addMonitorLayer(); + }); + } + } // 获取图斑面数据 const polygonVisibility = ref('none'); @@ -817,49 +864,13 @@ onMounted(() => { mapboxgl.accessToken = MAPBOX_TOKEN; - // 获取网络环境 - getNetworkType().then(res=>{ - if(res){ - networkType.value = "WAN"; - }else{ - networkType.value = "LAN"; - } + // 获取网络环境后加载地图 + loadMapInfo(); - map = initMap(); + }) - map.on('load', () => { - //挂载mapbox-gl-utils - U.init(map); - mp = new MP(map); + - // 添加地形数据 - map.addSource('mapbox-dem', { - type: 'raster-dem', - tiles: [VITE_GLOB_API_URL_VAR.value + '/mapbox_terrain/{z}/{x}/{y}.png'], - tileSize: 256, - maxzoom: 13, - minzoom: 10, - }); - // map.setTerrain({ source: 'mapbox-dem', exaggeration: 1 }); - - // 设置2D地图 - map.easeTo({ pitch: 0, bearing: 0, duration: 1000 }); - map.dragRotate.disable(); // 禁用拖动旋转 - map.pitchWithRotate = false; // 禁用旋转时俯仰变化 - mapAngle.value = '2D'; - - handlerCheckUserOrgs(); - // handlerLoadMaskLayer(); - getMaskData(); - handlerDealStreet(); - handlerDealCountry(); - - // 视频监控 - addMonitorLayer(); - }); - }); - - }) // 抛出函数 defineExpose({