add finishCondition to ol.interaction.Draw

This commit is contained in:
giohappy
2016-04-22 11:07:42 +02:00
parent 60926626df
commit 130b4d9459

View File

@@ -160,6 +160,13 @@ ol.interaction.Draw = function(options) {
*/
this.maxPoints_ = options.maxPoints ? options.maxPoints : Infinity;
/**
* A function to decide if a potential finish coordinate is permissable
* @private
* @type {ol.events.ConditionType}
*/
this.finishCondition_ = options.finishCondition ? options.finishCondition : goog.functions.TRUE;
var geometryFunction = options.geometryFunction;
if (!geometryFunction) {
if (this.type_ === ol.geom.GeometryType.CIRCLE) {
@@ -404,7 +411,9 @@ ol.interaction.Draw.handleUpEvent_ = function(event) {
} else if (this.mode_ === ol.interaction.DrawMode.CIRCLE) {
this.finishDrawing();
} else if (this.atFinish_(event)) {
this.finishDrawing();
if (this.finishCondition_(event)) {
this.finishDrawing();
}
} else {
this.addToDrawing_(event);
}