|
|
|
@ -738,15 +738,17 @@ export default { |
|
|
|
// 关键:使用 CallbackProperty 动态计算半径(半长轴和半短轴) |
|
|
|
semiMajorAxis: new Cesium.CallbackProperty(() => { |
|
|
|
if (centerPoint && activeCursorPosition) { |
|
|
|
return Cesium.Cartesian3.distance(centerPoint, activeCursorPosition); |
|
|
|
const distance = Cesium.Cartesian3.distance(centerPoint, activeCursorPosition); |
|
|
|
return Math.max(distance, 1); // 最小半径为1米,避免0值错误 |
|
|
|
} |
|
|
|
return 0; |
|
|
|
return 1; |
|
|
|
}, false), |
|
|
|
semiMinorAxis: new Cesium.CallbackProperty(() => { |
|
|
|
if (centerPoint && activeCursorPosition) { |
|
|
|
return Cesium.Cartesian3.distance(centerPoint, activeCursorPosition); |
|
|
|
const distance = Cesium.Cartesian3.distance(centerPoint, activeCursorPosition); |
|
|
|
return Math.max(distance, 1); // 最小半径为1米,避免0值错误 |
|
|
|
} |
|
|
|
return 0; |
|
|
|
return 1; |
|
|
|
}, false), |
|
|
|
// 样式设置 |
|
|
|
material: Cesium.Color.fromCssColorString(this.defaultStyles.polygon.color).withAlpha(0.5), |
|
|
|
@ -779,7 +781,8 @@ export default { |
|
|
|
const centerPoint = this.drawingPoints[0]; |
|
|
|
|
|
|
|
// 1. 计算最终半径 |
|
|
|
const radius = Cesium.Cartesian3.distance(centerPoint, edgePosition); |
|
|
|
let radius = Cesium.Cartesian3.distance(centerPoint, edgePosition); |
|
|
|
radius = Math.max(radius, 1); // 最小半径为1米,避免0值错误 |
|
|
|
|
|
|
|
// 2. 移除动态预览实体 |
|
|
|
if (this.tempEntity) { |
|
|
|
@ -1422,11 +1425,12 @@ export default { |
|
|
|
|
|
|
|
case 'circle': |
|
|
|
// 检查半径是否有效 |
|
|
|
const radius = entityData.data.radius || 1000 |
|
|
|
let radius = entityData.data.radius || 1000 |
|
|
|
if (radius <= 0) { |
|
|
|
this.$message.error('圆形半径必须大于0') |
|
|
|
return |
|
|
|
} |
|
|
|
radius = Math.max(radius, 1); // 最小半径为1米,避免0值错误 |
|
|
|
entity = this.viewer.entities.add({ |
|
|
|
position: Cesium.Cartesian3.fromDegrees(entityData.data.center.lng, entityData.data.center.lat), |
|
|
|
ellipse: { |
|
|
|
|