maxiaoxiao 3 月之前
父節點
當前提交
c8904a25a7
共有 1 個文件被更改,包括 40 次插入32 次删除
  1. 40 32
      src/views/farmlandProtection/gdzl/wrjxx.vue

+ 40 - 32
src/views/farmlandProtection/gdzl/wrjxx.vue

@@ -160,30 +160,35 @@ export default {
     },
     addImg(item, i) {
       console.log(item, "itemsx");
-      let image = this.geturl(item.photo_path);
-      // 创建Cesium的ImageMaterialProperty
-      const imageMaterial = new Cesium.ImageMaterialProperty({
-        image,
-        repeat: new Cesium.Cartesian2(1.0, 1.0), // 控制图像重复,这里设置为不重复
-        transparent: true, // 如果图像有透明通道,设置为true
-        hasAlpha: true,
-        material: new Cesium.ColorMaterialProperty(Cesium.Color.TRANSPARENT),
-      });
-      imgents[`${i}-${item.id} `] = img_entity.entities.add({
-        name: "Image",
-        id: item.id,
-        rectangle: {
-          coordinates: Cesium.Rectangle.fromDegrees(
-            item.pngenvelope[0],
-            item.pngenvelope[1],
-            item.pngenvelope[2],
-            item.pngenvelope[3]
-          ), // 设置矩形的经纬度范围
-          material: imageMaterial,
-          zIndex: 2000 - Number(item.id),
-        },
-      });
-      console.log("idddtem", "itemsx");
+      // let image = this.geturl(item.photo_path);
+
+      const image = new Image();
+      image.src = this.geturl(item.photo_path);
+      image.crossOrigin = "anonymous";
+      image.onload = function () {
+        // 创建Cesium的ImageMaterialProperty
+        const imageMaterial = new Cesium.ImageMaterialProperty({
+          image,
+          repeat: new Cesium.Cartesian2(1.0, 1.0), // 控制图像重复,这里设置为不重复
+          transparent: true, // 如果图像有透明通道,设置为true
+          hasAlpha: true,
+          material: new Cesium.ColorMaterialProperty(Cesium.Color.TRANSPARENT),
+        });
+        imgents[`${i}-${item.id} `] = img_entity.entities.add({
+          name: "Image",
+          id: item.id,
+          rectangle: {
+            coordinates: Cesium.Rectangle.fromDegrees(
+              item.pngenvelope[0],
+              item.pngenvelope[1],
+              item.pngenvelope[2],
+              item.pngenvelope[3]
+            ), // 设置矩形的经纬度范围
+            material: imageMaterial,
+            zIndex: 2000 - Number(item.id),
+          },
+        });
+      };
     },
     lineFly(uavitem) {
       this.stopPolylineFly(uavitem);
@@ -205,18 +210,20 @@ export default {
         flyManagers[uavitem.id].stopArrived.addEventListener(function (
           routeStop
         ) {
-          routeStop.waitTime = 0; // 在每个站点处停留1s
+          routeStop.waitTime = routeStop.index ? 0 : 2; // 在每个站点处停留1s
 
-          if (routeStop.index + 8 < uavitem.flightDtoList.length) {
-            that.addImg(uavitem.flightDtoList[routeStop.index + 4], uavitem.id);
+          if (routeStop.index + 10 < uavitem.flightDtoList.length) {
+            that.addImg(
+              uavitem.flightDtoList[routeStop.index + 10],
+              uavitem.id
+            );
           }
           // if (routeStop.index > 4)
-            img_entity.entities.remove(img_entity.entities.values[0]);
+          img_entity.entities.remove(img_entity.entities.values[0]);
           // imgents[`${uavitem.id}-${routeStop.index - 4}`]
           console.log(
             routeStop.index,
-            routeStop.index + 4,
-            routeStop.index - 4,
+            routeStop.index + 10,
             img_entity.entities
           );
         });
@@ -231,6 +238,7 @@ export default {
       this.addImg(uavitem.flightDtoList[3], uavitem.id);
       this.addImg(uavitem.flightDtoList[5], uavitem.id);
       this.addImg(uavitem.flightDtoList[7], uavitem.id);
+      this.addImg(uavitem.flightDtoList[9], uavitem.id);
       //初始化飞行管理
       // that.flyHOld = that.flyH;
       //注册站点到达事件
@@ -268,8 +276,8 @@ export default {
 
 <style lang="less" scoped>
 .wrjxx {
-  height: 705px;
-  margin: 20px;
+  height: 710px;
+  margin: 10px;
   overflow-x: hidden;
   overflow-y: auto;
 }