Merge pull request #12513 from ahocevar/draw-sketch-point

Draw a sketch point when adding a vertex programmatically
This commit is contained in:
Andreas Hocevar
2021-07-13 22:45:31 +02:00
committed by GitHub
+6 -6
View File
@@ -708,7 +708,7 @@ class Draw extends PointerInteraction {
if (this.finishCoordinate_) { if (this.finishCoordinate_) {
this.modifyDrawing_(event.coordinate); this.modifyDrawing_(event.coordinate);
} else { } else {
this.createOrUpdateSketchPoint_(event); this.createOrUpdateSketchPoint_(event.coordinate.slice());
} }
} }
@@ -758,11 +758,10 @@ class Draw extends PointerInteraction {
} }
/** /**
* @param {import("../MapBrowserEvent.js").default} event Event. * @param {import("../coordinate").Coordinate} coordinates Coordinate.
* @private * @private
*/ */
createOrUpdateSketchPoint_(event) { createOrUpdateSketchPoint_(coordinates) {
const coordinates = event.coordinate.slice();
if (!this.sketchPoint_) { if (!this.sketchPoint_) {
this.sketchPoint_ = new Feature(new Point(coordinates)); this.sketchPoint_ = new Feature(new Point(coordinates));
this.updateSketchFeatures_(); this.updateSketchFeatures_();
@@ -916,6 +915,7 @@ class Draw extends PointerInteraction {
} }
this.geometryFunction_(this.sketchCoords_, geometry, projection); this.geometryFunction_(this.sketchCoords_, geometry, projection);
} }
this.createOrUpdateSketchPoint_(coordinate.slice());
this.updateSketchFeatures_(); this.updateSketchFeatures_();
if (done) { if (done) {
this.finishDrawing(); this.finishDrawing();
@@ -942,7 +942,7 @@ class Draw extends PointerInteraction {
this.finishCoordinate_ = coordinates[coordinates.length - 2].slice(); this.finishCoordinate_ = coordinates[coordinates.length - 2].slice();
const finishCoordinate = this.finishCoordinate_.slice(); const finishCoordinate = this.finishCoordinate_.slice();
coordinates[coordinates.length - 1] = finishCoordinate; coordinates[coordinates.length - 1] = finishCoordinate;
this.sketchPoint_.setGeometry(new Point(finishCoordinate)); this.createOrUpdateSketchPoint_(finishCoordinate);
} }
this.geometryFunction_(coordinates, geometry, projection); this.geometryFunction_(coordinates, geometry, projection);
if (geometry.getType() === GeometryType.POLYGON && this.sketchLine_) { if (geometry.getType() === GeometryType.POLYGON && this.sketchLine_) {
@@ -955,7 +955,7 @@ class Draw extends PointerInteraction {
if (coordinates.length >= 2) { if (coordinates.length >= 2) {
const finishCoordinate = coordinates[coordinates.length - 2].slice(); const finishCoordinate = coordinates[coordinates.length - 2].slice();
coordinates[coordinates.length - 1] = finishCoordinate; coordinates[coordinates.length - 1] = finishCoordinate;
this.sketchPoint_.setGeometry(new Point(finishCoordinate)); this.createOrUpdateSketchPoint_(finishCoordinate);
} }
sketchLineGeom.setCoordinates(coordinates); sketchLineGeom.setCoordinates(coordinates);
this.geometryFunction_(this.sketchCoords_, geometry, projection); this.geometryFunction_(this.sketchCoords_, geometry, projection);