Allow passing undefined to ol.layer.Vector#setStyle

This commit is contained in:
Éric Lemoine
2014-08-27 09:38:08 +02:00
parent 68b3691cd6
commit 9cc0841efb
2 changed files with 28 additions and 19 deletions

View File

@@ -51,8 +51,7 @@ ol.layer.Vector = function(opt_options) {
*/
this.styleFunction_ = undefined;
this.setStyle(goog.isDefAndNotNull(options.style) ?
options.style : ol.style.defaultStyleFunction);
this.setStyle(options.style);
};
goog.inherits(ol.layer.Vector, ol.layer.Layer);
@@ -102,13 +101,14 @@ ol.layer.Vector.prototype.setRenderOrder = function(renderOrder) {
/**
* Set the style for features. This can be a single style object, an array
* of styles, or a function that takes a feature and resolution and returns
* an array of styles.
* @param {ol.style.Style|Array.<ol.style.Style>|ol.style.StyleFunction} style
* Layer style.
* an array of styles. If `undefined` default styles are used.
* @param {ol.style.Style|Array.<ol.style.Style>|ol.style.StyleFunction|undefined}
* style Layer style.
* @api stable
*/
ol.layer.Vector.prototype.setStyle = function(style) {
this.style_ = style;
this.styleFunction_ = ol.style.createStyleFunction(style);
this.style_ = goog.isDef(style) ? style : ol.style.defaultStyleFunction;
this.styleFunction_ = goog.isNull(style) ?
undefined : ol.style.createStyleFunction(this.style_);
this.dispatchChangeEvent();
};