mirror of
https://github.com/ethan-zf/cesium-plot-js.git
synced 2025-07-04 06:57:26 +00:00
Resolve event conflicts when drawing multiple shapes.
This commit is contained in:
parent
599f047e0a
commit
b7191a8054
@ -32,9 +32,8 @@ export default class AttackArrow extends Draw {
|
|||||||
} else if (this.points.length === 2) {
|
} else if (this.points.length === 2) {
|
||||||
this.setGeometryPoints(this.points);
|
this.setGeometryPoints(this.points);
|
||||||
this.addToMap();
|
this.addToMap();
|
||||||
this.lineEntity && this.viewer.entities.remove(this.lineEntity);
|
|
||||||
} else {
|
} else {
|
||||||
console.error('click...');
|
this.lineEntity && this.viewer.entities.remove(this.lineEntity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
20
src/draw.ts
20
src/draw.ts
@ -1,4 +1,3 @@
|
|||||||
import * as Utils from './utils';
|
|
||||||
import * as CesiumTypeOnly from '@examples/cesium';
|
import * as CesiumTypeOnly from '@examples/cesium';
|
||||||
import { State } from './interface';
|
import { State } from './interface';
|
||||||
|
|
||||||
@ -62,7 +61,8 @@ export default class Draw {
|
|||||||
this.removeControlPoints();
|
this.removeControlPoints();
|
||||||
}
|
}
|
||||||
} else if (this.state === 'static') {
|
} else if (this.state === 'static') {
|
||||||
if (hitEntities) {
|
//When drawing multiple shapes, the click events for all shapes are triggered. Only when hitting a completed shape should it enter editing mode.
|
||||||
|
if (hitEntities && this.polygonEntity.id === pickedObject.id.id) {
|
||||||
const pickedEntity = pickedObject.id;
|
const pickedEntity = pickedObject.id;
|
||||||
if (this.cesium.defined(pickedEntity.polygon)) {
|
if (this.cesium.defined(pickedEntity.polygon)) {
|
||||||
// Hit PolygonGraphics geometry.
|
// Hit PolygonGraphics geometry.
|
||||||
@ -91,7 +91,6 @@ export default class Draw {
|
|||||||
onDoubleClick() {
|
onDoubleClick() {
|
||||||
// this.eventHandler = new this.cesium.ScreenSpaceEventHandler(this.viewer.canvas);
|
// this.eventHandler = new this.cesium.ScreenSpaceEventHandler(this.viewer.canvas);
|
||||||
this.eventHandler.setInputAction((evt: any) => {
|
this.eventHandler.setInputAction((evt: any) => {
|
||||||
console.error('db click...');
|
|
||||||
this.finishDrawing();
|
this.finishDrawing();
|
||||||
}, this.cesium.ScreenSpaceEventType.LEFT_DOUBLE_CLICK);
|
}, this.cesium.ScreenSpaceEventType.LEFT_DOUBLE_CLICK);
|
||||||
}
|
}
|
||||||
@ -146,7 +145,7 @@ export default class Draw {
|
|||||||
this.lineEntity = this.viewer.entities.add({
|
this.lineEntity = this.viewer.entities.add({
|
||||||
polyline: {
|
polyline: {
|
||||||
positions: new this.cesium.CallbackProperty(() => this.geometryPoints, false),
|
positions: new this.cesium.CallbackProperty(() => this.geometryPoints, false),
|
||||||
width: 5,
|
width: 2,
|
||||||
// material: this.cesium.Color.RED,
|
// material: this.cesium.Color.RED,
|
||||||
clampToGround: true,
|
clampToGround: true,
|
||||||
},
|
},
|
||||||
@ -173,10 +172,19 @@ export default class Draw {
|
|||||||
addControlPoints() {
|
addControlPoints() {
|
||||||
const points = this.getPoints();
|
const points = this.getPoints();
|
||||||
this.controlPoints = points.map((position) => {
|
this.controlPoints = points.map((position) => {
|
||||||
|
// return this.viewer.entities.add({
|
||||||
|
// position,
|
||||||
|
// billboard: {
|
||||||
|
// image: './src/assets/circle_red.png',
|
||||||
|
// },
|
||||||
|
// });
|
||||||
|
|
||||||
return this.viewer.entities.add({
|
return this.viewer.entities.add({
|
||||||
position,
|
position,
|
||||||
billboard: {
|
point: {
|
||||||
image: './src/assets/circle_red.png',
|
pixelSize: 10,
|
||||||
|
heightReference: this.cesium.HeightReference.CLAMP_TO_GROUND,
|
||||||
|
color: this.cesium.Color.RED,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user