diff --git a/packages/geo/src/lib/geometry/shared/controls/draw.ts b/packages/geo/src/lib/geometry/shared/controls/draw.ts index db9dcb1dcb..2494125a1d 100644 --- a/packages/geo/src/lib/geometry/shared/controls/draw.ts +++ b/packages/geo/src/lib/geometry/shared/controls/draw.ts @@ -57,6 +57,11 @@ export class DrawControl { */ public select$: Subject = new Subject(); + /** + * Draw abort observable (abort drawn features) + */ + public abort$: Subject = new Subject(); + /** * Freehand mode observable (defaults to false) */ @@ -72,6 +77,7 @@ export class DrawControl { private olModifyInteraction: OlModify; private onDrawStartKey: EventsKey; private onDrawEndKey: EventsKey; + private onDrawAbortKey: EventsKey; private onDrawKey: EventsKey; private mousePosition: [number, number]; @@ -209,6 +215,7 @@ export class DrawControl { this.onDrawStartKey = olDrawInteraction.on('drawstart', (event: OlDrawEvent) => this.onDrawStart(event)); this.onDrawEndKey = olDrawInteraction.on('drawend', (event: OlDrawEvent) => this.onDrawEnd(event)); + this.onDrawAbortKey = olDrawInteraction.on('drawabort', (event: OlDrawEvent) => this.abort$.next(event.feature.getGeometry())); if (activateModifyAndSelect) { // Create a Modify interaction, add it to map and create a listener @@ -238,7 +245,7 @@ export class DrawControl { */ private removeOlInteractions() { this.unsubscribeKeyDown(); - unByKey([this.onDrawStartKey, this.onDrawEndKey, this.onDrawKey]); + unByKey([this.onDrawStartKey, this.onDrawEndKey, this.onDrawKey, this.onDrawAbortKey]); if (this.olMap) { this.olMap.removeInteraction(this.olDrawInteraction); diff --git a/packages/geo/src/lib/measure/measurer/measurer.component.ts b/packages/geo/src/lib/measure/measurer/measurer.component.ts index ea294df448..c69cec46ac 100644 --- a/packages/geo/src/lib/measure/measurer/measurer.component.ts +++ b/packages/geo/src/lib/measure/measurer/measurer.component.ts @@ -718,7 +718,11 @@ export class MeasurerComponent implements OnInit, OnDestroy { .subscribe((olGeometry: OlLineString | OlPolygon) => this.onDrawEnd(olGeometry)); this.drawChanges$$ = drawControl.changes$ .subscribe((olGeometry: OlLineString | OlPolygon) => this.onDrawChanges(olGeometry)); - + this.drawChanges$$ = drawControl.abort$ + .subscribe((olGeometry: OlLineString | OlPolygon) => { + this.clearTooltipsOfOlGeometry(olGeometry); + this.clearMeasures(); + }); drawControl.setOlMap(this.map.ol, false); }