Add features option to draw interaction
This commit is contained in:
@@ -388,7 +388,8 @@
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @typedef {Object} olx.interaction.DrawOptions
|
* @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
|
* @property {number|undefined} snapTolerance Pixel distance for snapping to the
|
||||||
* drawing finish (default is 12).
|
* drawing finish (default is 12).
|
||||||
* @property {ol.geom.GeometryType} type Drawing type ('Point', 'LineString',
|
* @property {ol.geom.GeometryType} type Drawing type ('Point', 'LineString',
|
||||||
|
|||||||
@@ -74,6 +74,13 @@ ol.interaction.Draw = function(options) {
|
|||||||
*/
|
*/
|
||||||
this.source_ = goog.isDef(options.source) ? options.source : null;
|
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.
|
* Pixel distance for snapping.
|
||||||
* @type {number}
|
* @type {number}
|
||||||
@@ -473,6 +480,9 @@ ol.interaction.Draw.prototype.finishDrawing_ = function(event) {
|
|||||||
sketchFeature.setGeometry(new ol.geom.MultiPolygon([coordinates]));
|
sketchFeature.setGeometry(new ol.geom.MultiPolygon([coordinates]));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!goog.isNull(this.features_)) {
|
||||||
|
this.features_.push(sketchFeature);
|
||||||
|
}
|
||||||
if (!goog.isNull(this.source_)) {
|
if (!goog.isNull(this.source_)) {
|
||||||
this.source_.addFeature(sketchFeature);
|
this.source_.addFeature(sketchFeature);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user