Răsfoiți Sursa

飞入修改

lkk 1 lună în urmă
părinte
comite
09f7e44ce0
1 a modificat fișierele cu 11 adăugiri și 21 ștergeri
  1. 11 21
      src/views/remote/farmland/index.vue

+ 11 - 21
src/views/remote/farmland/index.vue

@@ -327,7 +327,7 @@ export default {
       });
     },
     handleDownload() {
-      let zipfile = this.newObj.proxypath + ".zip";
+      const zipfile = this.newObj.proxypath + ".zip";
       window.open(`${zipfile}`);
     },
     tableClick(row) {
@@ -387,61 +387,51 @@ export default {
       this.drawer = false;
     },
     test(item) {
-      // 1. 提取公共样式配置,避免重复定义
       let highlightStyle = new Style({
         stroke: new Stroke({
           color: "rgba(255, 0, 0, 1)",
           width: 2,
         }),
       });
-
-      // 2. 确定当前操作的地图容器列表
       let mapNames = this.sjlx === 1 ? ["mapDiv"] : ["mapCon1", "mapCon2"];
-
-      // 3. 清除所有相关地图容器中的旧高亮图层
       mapNames.forEach((mapName) => {
         if (this.itemObj && window.map[mapName]) {
           window.map[mapName].removeLayer(this.itemObj);
         }
       });
-
-      // 4. 验证geom数据有效性
       if (!item.geom || item.geom === "") return;
 
       try {
-        // 5. 统一处理geom格式转换
         let geomData = item.geom;
         if (typeof geomData === "string") {
           geomData = parse(geomData);
         }
-
-        // 6. 创建矢量图层
         let features = new GeoJSON().readFeatures(geomData);
         this.itemObj = new VectorLayer({
           source: new VectorSource({ features }),
           style: highlightStyle,
           zIndex: 9999,
         });
-
-        // 7. 获取实体地理范围(优先使用geom范围,而非中心点)
         let extent = this.itemObj.getSource().getExtent();
-        if (!extent || extent.length !== 4) {
-          console.warn("无效的实体范围:", extent);
+        if (!extent) {  
+          console.warn("无法获取实体范围,无法执行飞入动画");
+          // 仅添加图层不执行动画
+          mapNames.forEach((mapName) => {
+            let map = window.map[mapName];
+            if (map) map.addLayer(this.itemObj);
+          });
           return;
         }
 
-        // 8. 对所有相关地图执行添加图层和基于实体范围的飞入动画
+        //对所有相关地图执行添加图层和基于范围的飞入动画
         mapNames.forEach((mapName) => {
           let map = window.map[mapName];
           if (map) {
-            // 添加新图层
             map.addLayer(this.itemObj);
-            // 基于实体范围的飞入动画(仅在第一个地图执行一次)
             if (mapName === mapNames[0]) {
               map.getView().fit(extent, {
-                duration: 2000, // 动画持续时间
-                padding: [50, 50, 50, 50], // 边界内边距,避免实体贴边
-                maxZoom: 16.5, // 最大缩放级别限制
+                duration: 2000,
+                callback: null,
               });
             }
           } else {