add finishCondition to ol.interaction.Draw
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user