Merge pull request #2059 from bartvde/draw-geometryname

Add geometryName option to ol.interaction.Draw (r=@elemoine)
This commit is contained in:
Bart van den Eijnden
2014-05-14 08:51:59 +02:00
3 changed files with 43 additions and 2 deletions

View File

@@ -182,6 +182,13 @@ ol.interaction.Draw = function(options) {
options.style : ol.interaction.Draw.getDefaultStyleFunction()
});
/**
* Name of the geometry attribute for newly created features.
* @type {string|undefined}
* @private
*/
this.geometryName_ = options.geometryName;
};
goog.inherits(ol.interaction.Draw, ol.interaction.Pointer);
@@ -350,7 +357,11 @@ ol.interaction.Draw.prototype.startDrawing_ = function(event) {
}
}
goog.asserts.assert(goog.isDef(geometry));
this.sketchFeature_ = new ol.Feature(geometry);
this.sketchFeature_ = new ol.Feature();
if (goog.isDef(this.geometryName_)) {
this.sketchFeature_.setGeometryName(this.geometryName_);
}
this.sketchFeature_.setGeometry(geometry);
this.updateSketchFeatures_();
this.dispatchEvent(new ol.DrawEvent(ol.DrawEventType.DRAWSTART,
this.sketchFeature_));