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