Situation:
When using Cesium to draw and edit ellipse entities, the following inconsistencies have been observed:
1.Manually Drawn Circular Entities:
Behavior: Users interactively draw circular entities and subsequently edit them by dragging the center and adjusting the radius.
Outcome: During this process, the circular entities respond correctly; both dragging the center and adjusting the radius are reflected accurately and in real-time on the map.
2.Loaded Circular Entities from Saved Data:
Behavior: The application loads circular entities from previously saved data and allows users to edit them.
Outcome: When attempting to drag the radius control point to decrease the circle’s size, it becomes impossible to reduce the radius beyond approximately 40 meters. This issue persists if the center point remains unmoved. However, if the center is first moved, subsequent adjustments to the radius function as expected, allowing further reduction below 40 meters.
code:
this.handler.setInputAction((event) => {
if (this.draggingPoint) {
const cartesian = this._getCartesianFromMouse(event.endPosition);
if (cartesian) {
if (this.draggingPoint.properties.isCircleCenter) {
this.center = cartesian;
this._updateEndPosition();
} else if (this.draggingPoint.properties.isCircleEnd) {
this.selectedCircle.position = new Cesium.ConstantPositionProperty(
this.center
);
let newRadius = Cesium.Cartesian3.distance(this.center, cartesian);
if (newRadius > 200000) {
newRadius = 200000;
const limitedPosition = computeEndPoint(
this.center,
newRadius,
this.viewer
);
this.draggingPoint.position = new Cesium.ConstantPositionProperty(
limitedPosition
);
} else {
this.draggingPoint.position = new Cesium.ConstantPositionProperty(
cartesian
);
}
this.radius = newRadius;
}
}
}
}, Cesium.ScreenSpaceEventType.MOUSE_MOVE);