mirror of
https://github.com/ethan-zf/cesium-plot-js.git
synced 2025-06-24 03:27:29 +00:00
Added event unbinding, fixed editing issues, and resolved problem of not deleting control points in edit mode.
This commit is contained in:
parent
badc4a57cd
commit
9bfef7defb
@ -49,6 +49,24 @@ const getCameraInfo = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
let geometry: any;
|
let geometry: any;
|
||||||
|
const dragStartHandler = () => {
|
||||||
|
console.error('start');
|
||||||
|
};
|
||||||
|
const drawUpdateHandler = (cartesian: Cesium.Cartesian3) => {
|
||||||
|
console.error('update', cartesian);
|
||||||
|
};
|
||||||
|
|
||||||
|
const drawEndHandler = (geometryPoints: any) => {
|
||||||
|
console.error('drawEnd', geometryPoints);
|
||||||
|
};
|
||||||
|
|
||||||
|
const editStartHandler = () => {
|
||||||
|
console.error('editStart');
|
||||||
|
};
|
||||||
|
|
||||||
|
const editEndHandler = (geometryPoints: any) => {
|
||||||
|
console.error('editEnd', geometryPoints);
|
||||||
|
};
|
||||||
const buttonGroup = document.getElementById('button-group') as HTMLElement;
|
const buttonGroup = document.getElementById('button-group') as HTMLElement;
|
||||||
buttonGroup.onclick = (evt) => {
|
buttonGroup.onclick = (evt) => {
|
||||||
const targetElement = evt.target as HTMLElement;
|
const targetElement = evt.target as HTMLElement;
|
||||||
@ -121,21 +139,20 @@ buttonGroup.onclick = (evt) => {
|
|||||||
break;
|
break;
|
||||||
case 'addEvent':
|
case 'addEvent':
|
||||||
if (geometry) {
|
if (geometry) {
|
||||||
geometry.on('drawStart', () => {
|
geometry.on('drawStart', dragStartHandler);
|
||||||
console.error('start');
|
geometry.on('drawUpdate', drawUpdateHandler);
|
||||||
});
|
geometry.on('drawEnd', drawEndHandler);
|
||||||
geometry.on('drawUpdate', (cartesian: Cesium.Cartesian3) => {
|
geometry.on('editStart', editStartHandler);
|
||||||
console.error('update', cartesian);
|
geometry.on('editEnd', editEndHandler);
|
||||||
});
|
}
|
||||||
geometry.on('drawEnd', (geometryPoints: any) => {
|
break;
|
||||||
console.error('drawEnd', geometryPoints);
|
case 'removeEvent':
|
||||||
});
|
if (geometry) {
|
||||||
geometry.on('editStart', () => {
|
geometry.off('drawStart', dragStartHandler);
|
||||||
console.error('editStart');
|
geometry.off('drawUpdate', drawUpdateHandler);
|
||||||
});
|
geometry.off('drawEnd', drawEndHandler);
|
||||||
geometry.on('editEnd', (geometryPoints: any) => {
|
geometry.off('editStart', editStartHandler);
|
||||||
console.error('editEnd', geometryPoints);
|
geometry.off('editEnd', editEndHandler);
|
||||||
});
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -54,6 +54,7 @@
|
|||||||
<button id="show">显示</button>
|
<button id="show">显示</button>
|
||||||
<button id="remove">删除</button>
|
<button id="remove">删除</button>
|
||||||
<button id="addEvent">绑定事件</button>
|
<button id="addEvent">绑定事件</button>
|
||||||
|
<button id="removeEvent">解绑事件</button>
|
||||||
</div>
|
</div>
|
||||||
<script>
|
<script>
|
||||||
window.CESIUM_BASE_URL = './examples/cesium';
|
window.CESIUM_BASE_URL = './examples/cesium';
|
||||||
|
2055
package-lock.json
generated
2055
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
13
src/base.ts
13
src/base.ts
@ -162,12 +162,13 @@ export default class Base {
|
|||||||
* redraw, resulting in a flicker. However, this seems to be a relatively reasonable
|
* redraw, resulting in a flicker. However, this seems to be a relatively reasonable
|
||||||
* approach given the current circumstances."
|
* approach given the current circumstances."
|
||||||
*/
|
*/
|
||||||
if (this.type === 'polygon') {
|
// TODO...
|
||||||
this.polygonEntity.polygon.hierarchy = new this.cesium.PolygonHierarchy(this.geometryPoints);
|
// if (this.type === 'polygon') {
|
||||||
this.outlineEntity.polyline.positions = [...this.geometryPoints, this.geometryPoints[0]];
|
// this.polygonEntity.polygon.hierarchy = new this.cesium.PolygonHierarchy(this.geometryPoints);
|
||||||
} else if (this.type === 'line') {
|
// this.outlineEntity.polyline.positions = [...this.geometryPoints, this.geometryPoints[0]];
|
||||||
this.lineEntity.polyline.positions = this.geometryPoints;
|
// } else if (this.type === 'line') {
|
||||||
}
|
// this.lineEntity.polyline.positions = this.geometryPoints;
|
||||||
|
// }
|
||||||
|
|
||||||
this.eventDispatcher.dispatchEvent('drawEnd', this.getPoints());
|
this.eventDispatcher.dispatchEvent('drawEnd', this.getPoints());
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user