Add features option to draw interaction

This commit is contained in:
Antoine Abt
2014-02-21 13:41:07 +01:00
parent ec832bdf6e
commit a971928bbe
2 changed files with 12 additions and 1 deletions

View File

@@ -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',

View File

@@ -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);
}