Update finishCoordinate in ol.interaction.Draw#removeLastPoint

And don't crash if the function is called but no feature is drawn
This commit is contained in:
Frederic Junod
2017-04-10 12:34:44 +02:00
parent aaf3256279
commit d97d5e5164
2 changed files with 56 additions and 0 deletions
+6
View File
@@ -603,12 +603,18 @@ ol.interaction.Draw.prototype.addToDrawing_ = function(event) {
* @api
*/
ol.interaction.Draw.prototype.removeLastPoint = function() {
if (!this.sketchFeature_) {
return;
}
var geometry = /** @type {ol.geom.SimpleGeometry} */ (this.sketchFeature_.getGeometry());
var coordinates, sketchLineGeom;
if (this.mode_ === ol.interaction.Draw.Mode_.LINE_STRING) {
coordinates = this.sketchCoords_;
coordinates.splice(-2, 1);
this.geometryFunction_(coordinates, geometry);
if (coordinates.length >= 2) {
this.finishCoordinate_ = coordinates[coordinates.length - 2].slice();
}
} else if (this.mode_ === ol.interaction.Draw.Mode_.POLYGON) {
coordinates = this.sketchCoords_[0];
coordinates.splice(-2, 1);