diff --git a/src/ol/layer/layergroup.js b/src/ol/layer/layergroup.js index c685a6ec2c..7338704c3e 100644 --- a/src/ol/layer/layergroup.js +++ b/src/ol/layer/layergroup.js @@ -56,7 +56,7 @@ ol.layer.Group = function(opt_options) { ol.Object.getChangeEventType(ol.layer.GroupProperty.LAYERS), this.handleLayersChanged_, false, this); - if (goog.isDef(layers)) { + if (goog.isDefAndNotNull(layers)) { if (goog.isArray(layers)) { layers = new ol.Collection(goog.array.clone(layers)); } else { @@ -145,13 +145,13 @@ ol.layer.Group.prototype.handleLayersRemove_ = function(collectionEvent) { /** - * @return {ol.Collection.|undefined} Collection of + * @return {!ol.Collection.} Collection of * {@link ol.layer.Layer layers} that are part of this group. * @observable * @api stable */ ol.layer.Group.prototype.getLayers = function() { - return /** @type {ol.Collection.|undefined} */ (this.get( + return /** @type {!ol.Collection.} */ (this.get( ol.layer.GroupProperty.LAYERS)); }; goog.exportProperty( @@ -161,7 +161,7 @@ goog.exportProperty( /** - * @param {ol.Collection.|undefined} layers Collection of + * @param {!ol.Collection.} layers Collection of * {@link ol.layer.Layer layers} that are part of this group. * @observable * @api stable diff --git a/src/ol/map.js b/src/ol/map.js index 245d40991a..0f3dce3e9d 100644 --- a/src/ol/map.js +++ b/src/ol/map.js @@ -495,7 +495,6 @@ ol.Map.prototype.addInteraction = function(interaction) { */ ol.Map.prototype.addLayer = function(layer) { var layers = this.getLayerGroup().getLayers(); - goog.asserts.assert(goog.isDef(layers)); layers.push(layer); }; @@ -703,16 +702,12 @@ goog.exportProperty( /** * Get the collection of layers associated with this map. - * @return {ol.Collection.|undefined} Layers. + * @return {!ol.Collection.} Layers. * @api stable */ ol.Map.prototype.getLayers = function() { - var layerGroup = this.getLayerGroup(); - if (goog.isDef(layerGroup)) { - return layerGroup.getLayers(); - } else { - return undefined; - } + var layers = this.getLayerGroup().getLayers(); + return layers; }; @@ -1147,7 +1142,6 @@ ol.Map.prototype.removeInteraction = function(interaction) { */ ol.Map.prototype.removeLayer = function(layer) { var layers = this.getLayerGroup().getLayers(); - goog.asserts.assert(goog.isDef(layers)); return layers.remove(layer); };