diff --git a/src/objectliterals.jsdoc b/src/objectliterals.jsdoc index 566108902a..0016c4f946 100644 --- a/src/objectliterals.jsdoc +++ b/src/objectliterals.jsdoc @@ -388,7 +388,8 @@ /** * @typedef {Object} olx.interaction.DrawOptions - * @property {ol.source.Vector|undefined} source Destination source for the features. + * @property {ol.Collection|undefined} features Destination collection for the drawn features. + * @property {ol.source.Vector|undefined} source Destination source for the drawn features. * @property {number|undefined} snapTolerance Pixel distance for snapping to the * drawing finish (default is 12). * @property {ol.geom.GeometryType} type Drawing type ('Point', 'LineString', diff --git a/src/ol/interaction/drawinteraction.js b/src/ol/interaction/drawinteraction.js index 9a263bc38b..7c357ad51f 100644 --- a/src/ol/interaction/drawinteraction.js +++ b/src/ol/interaction/drawinteraction.js @@ -74,6 +74,13 @@ ol.interaction.Draw = function(options) { */ this.source_ = goog.isDef(options.source) ? options.source : null; + /** + * Target collection for drawn features. + * @type {ol.Collection} + * @private + */ + this.features_ = goog.isDef(options.features) ? options.features : null; + /** * Pixel distance for snapping. * @type {number} @@ -473,6 +480,9 @@ ol.interaction.Draw.prototype.finishDrawing_ = function(event) { sketchFeature.setGeometry(new ol.geom.MultiPolygon([coordinates])); } + if (!goog.isNull(this.features_)) { + this.features_.push(sketchFeature); + } if (!goog.isNull(this.source_)) { this.source_.addFeature(sketchFeature); }