@jorgmoritz/gis-manager 0.1.37 → 0.1.38

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/vue/index.js CHANGED
@@ -8248,7 +8248,9 @@ var PolygonEditor = class {
8248
8248
  polygon: {
8249
8249
  hierarchy: positions,
8250
8250
  material: faceColor,
8251
- outline: false
8251
+ outline: false,
8252
+ // 🔧 修复:设置 heightReference 使多边形贴合地形
8253
+ heightReference: C.HeightReference.CLAMP_TO_GROUND
8252
8254
  }
8253
8255
  });
8254
8256
  const ring = positions.slice();
@@ -8261,15 +8263,51 @@ var PolygonEditor = class {
8261
8263
  width: 1,
8262
8264
  material: lineColor,
8263
8265
  clampToGround: true
8266
+ // 轮廓线已经设置了 clampToGround
8264
8267
  },
8265
8268
  properties: { _ownerId: id, _type: "polygon-outline" }
8266
8269
  });
8267
8270
  this.applyDashedOutlineStyle(outlineEntity, lineColor, 3, 10);
8268
8271
  const displayText = name.includes("_") ? name.split("_")[1] : name;
8272
+ const firstPoint = points[0];
8273
+ this.createLabelWithTerrainHeight(
8274
+ layer,
8275
+ id,
8276
+ displayText,
8277
+ firstPoint.lon,
8278
+ firstPoint.lat,
8279
+ lineColor
8280
+ );
8281
+ return entity;
8282
+ } catch (err) {
8283
+ console.error(`[PolygonEditor] \u521B\u5EFA\u591A\u8FB9\u5F62\u5931\u8D25:`, err);
8284
+ return null;
8285
+ }
8286
+ }
8287
+ /**
8288
+ * 辅助方法:使用地形采样创建标签
8289
+ * 先尝试获取地形高度,如果失败则使用 heightReference
8290
+ */
8291
+ async createLabelWithTerrainHeight(layer, ownerId, displayText, lon, lat, lineColor) {
8292
+ const C = this.CesiumNS;
8293
+ try {
8294
+ let terrainHeight = 0;
8295
+ const terrainProvider = this.viewer.terrainProvider;
8296
+ if (terrainProvider && typeof C.sampleTerrainMostDetailed === "function") {
8297
+ try {
8298
+ const positions = [C.Cartographic.fromDegrees(lon, lat)];
8299
+ const updatedPositions = await C.sampleTerrainMostDetailed(terrainProvider, positions);
8300
+ if (updatedPositions && updatedPositions[0] && updatedPositions[0].height !== void 0) {
8301
+ terrainHeight = updatedPositions[0].height;
8302
+ }
8303
+ } catch (e) {
8304
+ }
8305
+ }
8306
+ const labelPosition = C.Cartesian3.fromDegrees(lon, lat, terrainHeight + 1);
8269
8307
  layer.entities.add({
8270
- id: `${id}-label`,
8308
+ id: `${ownerId}-label`,
8271
8309
  name: "Polygon Label",
8272
- position: positions[0],
8310
+ position: labelPosition,
8273
8311
  label: {
8274
8312
  text: displayText,
8275
8313
  font: "bold 16px Microsoft YaHei, SimHei, sans-serif",
@@ -8279,14 +8317,14 @@ var PolygonEditor = class {
8279
8317
  style: C.LabelStyle.FILL_AND_OUTLINE,
8280
8318
  verticalOrigin: C.VerticalOrigin.BOTTOM,
8281
8319
  pixelOffset: new C.Cartesian2(0, -10),
8282
- disableDepthTestDistance: Number.POSITIVE_INFINITY
8320
+ disableDepthTestDistance: Number.POSITIVE_INFINITY,
8321
+ // 仍然设置 heightReference 作为备用
8322
+ heightReference: C.HeightReference.CLAMP_TO_GROUND
8283
8323
  },
8284
- properties: { _ownerId: id, _type: "polygon-label" }
8324
+ properties: { _ownerId: ownerId, _type: "polygon-label" }
8285
8325
  });
8286
- return entity;
8287
- } catch (err) {
8288
- console.error(`[PolygonEditor] \u521B\u5EFA\u591A\u8FB9\u5F62\u5931\u8D25:`, err);
8289
- return null;
8326
+ } catch (e) {
8327
+ console.warn(`[PolygonEditor] \u521B\u5EFA\u6807\u7B7E\u5931\u8D25:`, e);
8290
8328
  }
8291
8329
  }
8292
8330
  /**