Jelajahi Sumber

feat:添加物候期分布和长势等级图层

wangsisi 2 minggu lalu
induk
melakukan
bd9179118b

+ 1 - 1
src/components/fnHeader.vue

@@ -140,7 +140,7 @@ const getGardenList = () => {
 const time = ref("");
 const timer = ref(null);
 onMounted(() => {
-    getGardenList();
+    // getGardenList();
     timer.value = setInterval(() => {
         time.value = getCurrentFormattedTime(new Date());
     }, 1000);

+ 6 - 1
src/utils/ol-map/StaticImgLayer.js

@@ -43,6 +43,10 @@ class StaticImgLayer extends LTBaseObject{
 			zIndex = options.zIndex
 		}
 		const vm = this
+		// imageExtent 是必需的,用于定义图片的地理范围
+		if (!options.extent) {
+			console.warn('StaticImgLayer: options.extent is required for image layer');
+		}
 		vm.source = new Static({
 			url, // 替换为你的GeoJSON文件URL
 			projection: 'EPSG:4326',
@@ -55,7 +59,8 @@ class StaticImgLayer extends LTBaseObject{
 			minZoom:minZoom,
 			opacity:opacity,
 			zIndex:zIndex,
-			extent:options.extent || [Infinity, -Infinity, -Infinity, Infinity]
+			// 如果提供了 extent,使用它;否则不设置 extent,让 OpenLayers 自动计算
+			...(options.extent && { extent: options.extent })
 		})
 
 		if(options && options.padding != undefined){

+ 7 - 1
src/views/warningHome/index.vue

@@ -76,10 +76,15 @@ const handleBaseTabClick = (tab) => {
     activeBaseTab.value = tab;
     showPoint.value = false
     staticMapPointLayers.hidePoint()
+    staticMapLayers.hideAll()
     if (tab === "资源") {
         staticMapPointLayers.showPoint()
     }else if (tab === "灌渠与泵站") {
         showPoint.value = true
+    }else if (tab === "长势等级") {
+        staticMapLayers.showSingle("Dongguan长势", false);
+    }else if (tab === "物候期分布") {
+        staticMapLayers.showSingle("Dongguan物候期", false);
     }
 };
 
@@ -127,7 +132,8 @@ onMounted(async () => {
     eventBus.emit("warningMap:init", warningMap.kmap);
 
     staticMapLayers.initStaticMapLayers(warningMap.kmap);
-    
+    staticMapLayers.showSingle("Dongguan物候期", false);
+
     // 图例数据
     eventBus.on("alarmList:warningLayers", (data) => {
         warningLayers.value = data;