瀏覽代碼

图斑上图文本

maxiaoxiao 5 月之前
父節點
當前提交
6a378b4ea4
共有 2 個文件被更改,包括 19 次插入20 次删除
  1. 17 19
      src/utils/MapHelper/help.js
  2. 2 1
      src/views/LandConsolidation/components/sdgk.vue

+ 17 - 19
src/utils/MapHelper/help.js

@@ -77,27 +77,25 @@ export function loadGeoJSON(geom, yanse, adata, fun) {
         // };
       }
       if (adata.name && entity.polygon) {
-        let center = getCentroid(geojson, ei);
-        entity.position = Cesium.Cartesian3.fromDegrees(
-          center[0],
-          center[1],
-          adata.lab_height || 0
-        );
-        entity.label = {
-          font: "bolder 18px sans-serif",
-          distanceDisplayCondition: new Cesium.DistanceDisplayCondition(100, adata.lab_max || 10000),
-          style: Cesium.LabelStyle.FILL_AND_OUTLINE,
-          text: adata.name, //图标名称
-          fillColor: Cesium.Color.fromCssColorString(yanse),
-          pixelOffset: new Cesium.Cartesian2(0, -20),
-          zIndex: 3,
-        };
-        console.log(entity, adata.name, '---')
+        if (!adata.lab_pos || !ei) {
+          let center = adata.lab_pos ? parse(adata.lab_pos).coordinates : getCentroid(geojson, ei);
+          entity.position = Cesium.Cartesian3.fromDegrees(
+            center[0],
+            center[1],
+            adata.lab_height || 0
+          );
+          entity.label = {
+            font: "bolder 18px sans-serif",
+            distanceDisplayCondition: new Cesium.DistanceDisplayCondition(100, adata.lab_max || 10000),
+            style: Cesium.LabelStyle.FILL_AND_OUTLINE,
+            text: adata.name, //图标名称
+            fillColor: Cesium.Color.fromCssColorString(yanse),
+            pixelOffset: new Cesium.Cartesian2(0, -20),
+            zIndex: 3,
+          };
+        }
       }
-
     });
-
-
   });
   // let polygon = Cesium.GeoJsonDataSource.load(geojson, {
   //   clampToGround: true,

+ 2 - 1
src/views/LandConsolidation/components/sdgk.vue

@@ -219,7 +219,8 @@ export default {
             {
               isfly: false,
               name: res.name,
-              lab_max: res.type ? 1000 : 100000,
+              lab_pos: res.centroid,
+              lab_max: res.type ? 3000 : 100000,
             },
             (data) => {
               geoSources[ri] = data;