Browse Source

三维分析定位,添加地块编码文本显示设置

maxiaoxiao 9 months ago
parent
commit
29f1083d1e
1 changed files with 29 additions and 2 deletions
  1. 29 2
      src/views/siteselection/components/xzjg.vue

+ 29 - 2
src/views/siteselection/components/xzjg.vue

@@ -314,7 +314,7 @@ export default {
     },
 
     // 加载GeoJSON数据
-    loadGeoJSON(geojson, yanse, id, height) {
+    loadGeoJSON(geojson, yanse, id, height, name) {
       let _this = this;
       let fcolor =
         id && id != "all"
@@ -332,6 +332,7 @@ export default {
         .then((data) => {
           viewer.dataSources.add(data);
           let entities = data.entities.values;
+          let addlabel = false;
           if (!geojson.type.includes("Polygon") || height) {
             entities.forEach((entity) => {
               if (entity.billboard) {
@@ -346,6 +347,23 @@ export default {
                 entity.polygon.material = Cesium.Color.WHITE;
                 entity.polygon.outlineColor = Cesium.Color.BLACK;
                 entity.polygon.outlineWidth = 1.0;
+                if (!addlabel) {
+                  var polycenter = Cesium.Cartesian3.fromDegrees(
+                    geojson.coordinates[0][0][0],
+                    geojson.coordinates[0][0][1],
+                    100
+                  );
+                  entity.position = polycenter;
+                  entity.label = {
+                    font: "bolder 18px sans-serif",
+                    style: Cesium.LabelStyle.FILL_AND_OUTLINE,
+                    text: name, //图标名称
+                    fillColor: Cesium.Color.fromCssColorString("#fff000"),
+                    pixelOffset: new Cesium.Cartesian2(5, -15),
+                    zIndex: 3,
+                  };
+                  addlabel = true;
+                }
               }
             });
           }
@@ -403,6 +421,12 @@ export default {
     },
     threeInfo(e, item) {
       this.$refs.dkDetails.show(item, "三维分析");
+      let upid = "up" + item.id;
+      if (dataSources[upid])
+        viewer.flyTo(dataSources[upid], {
+          offset: new Cesium.HeadingPitchRange(0, -0.8, 3000),
+        });
+        else this.mapview(item)
     },
 
     deleteprogramme(e, item) {
@@ -435,7 +459,7 @@ export default {
     pullUp(item, height) {
       let upid = "up" + item.id;
       if (!dataSources[upid])
-        this.loadGeoJSON(parse(item.geom), "#000000", upid, height);
+        this.loadGeoJSON(parse(item.geom), "#000000", upid, height, item.dkbm);
       else {
         let entities = dataSources[upid].entities.values;
         entities.forEach((entity) => {
@@ -443,6 +467,9 @@ export default {
             entity.polygon.extrudedHeight = height;
           }
         });
+        viewer.flyTo(dataSources[upid], {
+          offset: new Cesium.HeadingPitchRange(0, -0.8, 3000),
+        });
       }
     },
     pullClear(item) {