dianlixunjian
徐景良 2024-11-26 09:49:19 +08:00
parent 1f92a8832f
commit ff1e2e08c6
1 changed files with 51 additions and 40 deletions

View File

@ -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<String>('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({