Explorar el Código

驾驶舱上图修改

maxiaoxiao hace 10 meses
padre
commit
4456ef31f9

+ 30 - 12
src/views/cockpit/common/VectorSpace/BoxCommonVector.vue

@@ -185,6 +185,7 @@ export default {
     },
     goLayer(geom, lid) {
       if (tdsy.layer) tdsy.layer.show = false;
+      // tdsy.removelayer();
       let layer = viewer.imageryLayers.addImageryProvider(
         new Cesium.SuperMapImageryProvider({
           url: this.layersData.url,
@@ -194,18 +195,25 @@ export default {
       tdsy.layersObj[lid] = layer;
       this.loadGeoJSON(geom, lid);
     },
-    loadGeoJSON(geojson, id) {
+    loadGeoJSON(geojson, id, yanse, isfly = true) {
       let polygon = Cesium.GeoJsonDataSource.load(geojson, {
         clampToGround: true,
-        stroke: Cesium.Color.RED.withAlpha(0),
-        fill: Cesium.Color.WHITE.withAlpha(0),
+        stroke: yanse
+          ? Cesium.Color.fromCssColorString(yanse)
+          : Cesium.Color.RED.withAlpha(0),
+        fill: yanse
+          ? Cesium.Color.fromCssColorString(yanse).withAlpha(0.3)
+          : Cesium.Color.WHITE.withAlpha(0),
+        strokeWidth: isfly ? 5 : 2,
+        zIndex: isfly ? 10 : 5,
       });
       polygon.then(function (dataSource) {
         viewer.dataSources.add(dataSource);
         layerSources[id] = dataSource;
-        viewer.flyTo(dataSource, {
-          offset: new Cesium.HeadingPitchRange(0, -45),
-        });
+        if (isfly)
+          viewer.flyTo(dataSource, {
+            offset: new Cesium.HeadingPitchRange(0, -45),
+          });
       });
     },
     multiPolygonToPolygons(multiPolygon) {
@@ -361,7 +369,11 @@ export default {
       } else {
         if (this.cockpit_vector.mapType) {
           this.setLayerStatus(item);
-        } else this.addpolygon(item);
+        } else {
+          // this.addpolygon(item);
+          this.tempdataLayerId = "h_" + item.index;
+          this.loadGeoJSON(item.geom, "h_" + item.index, "#ff0000");
+        }
       }
       store.setVectordataid(item.dataid);
       let arr = [];
@@ -579,7 +591,13 @@ export default {
     active_dableData(newVal, oldVal) {
       if (this.cockpit_vector.mapType)
         this.draw_vector_server(this.cockpit_vector.mapType);
-      else this.draw_vector_tdgy_gy_jd(newVal);
+      // else this.draw_vector_tdgy_gy_jd(newVal);
+      else {
+        newVal.forEach((res, index) => {
+          res.index = index;
+          if (res.geom) this.loadGeoJSON(res.geom, index, "#55A1E3", false);
+        });
+      }
     },
     tempdataLayerId(newVal, oldVal) {
       if (oldVal && tdsy.layersObj[oldVal]) {
@@ -693,9 +711,9 @@ div::-webkit-scrollbar {
     line-height: 23px;
     padding: 0 5px;
     border-radius: 4px;
-    top: -1.9rem !important;
-    position: relative;
-    right: -24rem;
+    top: 10px !important;
+    position: absolute;
+    right: 20px;
   }
 
   .PangetitleVector {
@@ -707,7 +725,7 @@ div::-webkit-scrollbar {
     line-height: 35px;
     font-size: 14px;
     padding-left: 15px;
-    display: flex;
+    // display: flex;
     position: relative;
     overflow: hidden;
   }

+ 11 - 0
src/views/cockpit/js/tdsy.js

@@ -53,6 +53,8 @@ export const remove = (isreset) => {
         viewer.dataSources.remove(gy_jd_entity);
         gy_jd_entity = null
     }
+    viewer.entities.removeAll();
+    viewer.dataSources.removeAll();
     if (layer && isreset) {
         viewer.imageryLayers.remove(layer);
         layer = null
@@ -77,6 +79,15 @@ export const remove = (isreset) => {
     //     })
     // }
 
+}
+export const removelayer = () => {
+    console.log("---aa", viewer.imageryLayers)
+    if (layer) {
+        console.log("----", layer)
+        viewer.imageryLayers.remove(layer);
+        layer = null
+    }
+
 }
 
 export const hidden = (flag) => {