Răsfoiți Sursa

添加geojson

maxiaoxiao 11 luni în urmă
părinte
comite
1be06071d5

+ 15 - 15
src/components/mapView/range.vue

@@ -105,9 +105,9 @@ export default {
       this.addPolygon();
       ShapeUpload(formdata).then((res) => {
         if (res.success) {
-          var layer = myMap.addGeoJson("common_layer", res.data.geojson);
-          var url = `${SYS_LAYERS.XZQXZ}/0/query`;
-          var geom = layer.getSource().getFeatures()[0].getGeometry();
+          // var layer = myMap.addGeoJson("common_layer", res.data.geojson);
+          // var url = `${SYS_LAYERS.XZQXZ}/0/query`;
+          // var geom = layer.getSource().getFeatures()[0].getGeometry();
           // 判断绘制范围是否在行政区范围内
           let withinRange = true;
           // arcMap.SearchWfsData(url, geom, function (fs) {
@@ -121,18 +121,18 @@ export default {
           //   } else {
           //     withinRange = false;
           //   }
-          //   if (withinRange) {
-          //     this.model.xzfw = res.data.filepath;
-          //     this.model.feature = layer.getSource().getFeatures()[0];
-          //     this.model.xzmj = new OLTool().Tools.formatArea(
-          //       this.model.feature.getGeometry(),
-          //       true
-          //     );
-          //     myMap.zoomToextent(layer.getSource().getExtent());
-          //   } else {
-          //     this.clearAll();
-          //     ElMessage.warning("分析范围超出了权限范围,请重新上传文件!");
-          //   }
+          if (withinRange) {
+            this.model.xzfw = res.data.filepath;
+            //     this.model.feature = layer.getSource().getFeatures()[0];
+            //     this.model.xzmj = new OLTool().Tools.formatArea(
+            //       this.model.feature.getGeometry(),
+            //       true
+            //     );
+            //     myMap.zoomToextent(layer.getSource().getExtent());
+          } else {
+            //     this.clearAll();
+            //     ElMessage.warning("分析范围超出了权限范围,请重新上传文件!");
+          }
           // });
         }
       });

+ 0 - 1
src/views/complianceAnalysis/components/hgxsc.vue

@@ -77,7 +77,6 @@ export default {
   data() {
     return {
       xz: [],
-
       treedata: [
         {
           id: 1,

+ 12 - 1
src/views/complianceAnalysis/components/lsjl.vue

@@ -173,7 +173,18 @@ export default {
         this.datalist = res.data;
       });
     },
-    zoomItem(item) {},
+    zoomItem(item) {
+      this.addPolygon(item.bsm);
+    },
+    // 加载GeoJSON数据
+    addPolygon(geojson) {
+      viewer.dataSources.removeAll();
+      let polygon = Cesium.GeoJsonDataSource.load(geojson);
+      polygon.then(function (dataSource) {
+        viewer.dataSources.add(dataSource);
+        viewer.zoomTo(dataSource);
+      });
+    },
   },
 
   // watch(

+ 1 - 4
src/views/complianceAnalysis/components/scjg.vue

@@ -73,9 +73,8 @@ export default {
       this.echarts[i].iseyes = !this.echarts[i].iseyes;
       let label = this.echarts[i].label;
       let id = "scjg" + i;
-      console.log("----", this.dataSources, id);
       if (this.dataSources[id]) {
-        this.dataSources[id].show = item.iseyes;
+        this.dataSources[id].show = this.echarts[i].iseyes;
       } else this.addPolygon(label, id);
       // emit("eyesChaneg");
     },
@@ -108,13 +107,11 @@ export default {
         { clampToGround: true }
       );
       polygon.then(function (dataSource) {
-        console.log("----", _this);
         // dataSource.id = id;
         // 将数据源添加到Cesium Viewer
         viewer.dataSources.add(dataSource);
         viewer.zoomTo(dataSource);
         _this.dataSources[id] = dataSource;
-        console.log(_this.dataSources);
         // 可以获取实体并进行操作
         // dataSource.entities.values.forEach((entity) => {
         //   // 你可以在这里设置实体的属性,例如位置、颜色等