As it is currently used, opt_options is not optional

It would be nice if the compiler would warn us of things like this (accessing properties of undefined).
This commit is contained in:
Tim Schaub
2014-02-07 13:48:32 -07:00
parent 6db054353f
commit 2fc15a5bf0
+8 -8
View File
@@ -60,10 +60,10 @@ goog.inherits(ol.DrawEvent, goog.events.Event);
* Interaction that allows drawing geometries * Interaction that allows drawing geometries
* @constructor * @constructor
* @extends {ol.interaction.Interaction} * @extends {ol.interaction.Interaction}
* @param {olx.interaction.DrawOptions=} opt_options Options. * @param {olx.interaction.DrawOptions} options Options.
* @todo stability experimental * @todo stability experimental
*/ */
ol.interaction.Draw = function(opt_options) { ol.interaction.Draw = function(options) {
goog.base(this); goog.base(this);
@@ -72,22 +72,22 @@ ol.interaction.Draw = function(opt_options) {
* @type {ol.source.Vector} * @type {ol.source.Vector}
* @private * @private
*/ */
this.source_ = goog.isDef(opt_options.source) ? opt_options.source : null; this.source_ = goog.isDef(options.source) ? options.source : null;
/** /**
* Pixel distance for snapping. * Pixel distance for snapping.
* @type {number} * @type {number}
* @private * @private
*/ */
this.snapTolerance_ = goog.isDef(opt_options.snapTolerance) ? this.snapTolerance_ = goog.isDef(options.snapTolerance) ?
opt_options.snapTolerance : 12; options.snapTolerance : 12;
/** /**
* Geometry type. * Geometry type.
* @type {ol.geom.GeometryType} * @type {ol.geom.GeometryType}
* @private * @private
*/ */
this.type_ = opt_options.type; this.type_ = options.type;
/** /**
* Drawing mode (derived from geometry type. * Drawing mode (derived from geometry type.
@@ -147,8 +147,8 @@ ol.interaction.Draw = function(opt_options) {
* @private * @private
*/ */
this.overlay_ = new ol.FeatureOverlay(); this.overlay_ = new ol.FeatureOverlay();
this.overlay_.setStyleFunction(goog.isDef(opt_options.styleFunction) ? this.overlay_.setStyleFunction(goog.isDef(options.styleFunction) ?
opt_options.styleFunction : ol.interaction.Draw.defaultStyleFunction options.styleFunction : ol.interaction.Draw.defaultStyleFunction
); );
}; };
goog.inherits(ol.interaction.Draw, ol.interaction.Interaction); goog.inherits(ol.interaction.Draw, ol.interaction.Interaction);