From 15a9ae1e95077ce3950e0f04e36776faf9a0d927 Mon Sep 17 00:00:00 2001 From: ethan Date: Thu, 24 Aug 2023 15:55:04 +0800 Subject: [PATCH] Add Lifecycle Events --- examples/index.ts | 25 +++++++++++++++++++++- index.html | 31 ++++++++++++++------------- src/base.ts | 38 +++++++++++++++++++++++++++++++-- src/events.ts | 37 ++++++++++++++++++++++++++++++++ src/interface.ts | 3 +++ src/line/freehand-line.ts | 1 + src/polygon/freehand-polygon.ts | 1 + 7 files changed, 118 insertions(+), 18 deletions(-) create mode 100644 src/events.ts diff --git a/examples/index.ts b/examples/index.ts index f6d1831..9fa6614 100644 --- a/examples/index.ts +++ b/examples/index.ts @@ -103,7 +103,11 @@ buttonGroup.onclick = (evt) => { geometry = new CesiumPlot.FreehandLine(Cesium, viewer); break; case 'drawFreehandPolygon': - geometry = new CesiumPlot.FreehandPolygon(Cesium, viewer); + geometry = new CesiumPlot.FreehandPolygon(Cesium, viewer, { + material: Cesium.Color.GREEN, + outlineMaterial: Cesium.Color.fromCssColorString('rgba(59, 178, 208, 1)'), + outlineWidth: 2, + }); break; case 'hide': geometry && geometry.hide(); @@ -115,6 +119,25 @@ buttonGroup.onclick = (evt) => { geometry && geometry.remove(); geometry = null; break; + case 'addEvent': + if (geometry) { + geometry.on('drawStart', () => { + console.error('start'); + }); + geometry.on('drawUpdate', (cartesian: Cesium.Cartesian3) => { + console.error('update', cartesian); + }); + geometry.on('drawEnd', (geometryPoints: any) => { + console.error('drawEnd', geometryPoints); + }); + geometry.on('editStart', () => { + console.error('editStart'); + }); + geometry.on('editEnd', (geometryPoints: any) => { + console.error('editEnd', geometryPoints); + }); + } + break; default: break; } diff --git a/index.html b/index.html index d6d0f7e..c27425d 100644 --- a/index.html +++ b/index.html @@ -24,7 +24,7 @@ justify-content: center; } - .button { + .button-container button { margin: 0 10px; padding: 6px 10px; background-color: #3498db; @@ -39,20 +39,21 @@
- - - - - - - - - - - - - - + + + + + + + + + + + + + + +