Merge pull request #2675 from fredj/map.getlayers

Remove undefined from ol.Map#getLayers return type
This commit is contained in:
Frédéric Junod
2014-09-08 16:30:47 +02:00
2 changed files with 7 additions and 13 deletions
+4 -4
View File
@@ -56,7 +56,7 @@ ol.layer.Group = function(opt_options) {
ol.Object.getChangeEventType(ol.layer.GroupProperty.LAYERS), ol.Object.getChangeEventType(ol.layer.GroupProperty.LAYERS),
this.handleLayersChanged_, false, this); this.handleLayersChanged_, false, this);
if (goog.isDef(layers)) { if (goog.isDefAndNotNull(layers)) {
if (goog.isArray(layers)) { if (goog.isArray(layers)) {
layers = new ol.Collection(goog.array.clone(layers)); layers = new ol.Collection(goog.array.clone(layers));
} else { } else {
@@ -145,13 +145,13 @@ ol.layer.Group.prototype.handleLayersRemove_ = function(collectionEvent) {
/** /**
* @return {ol.Collection.<ol.layer.Base>|undefined} Collection of * @return {!ol.Collection.<ol.layer.Base>} Collection of
* {@link ol.layer.Layer layers} that are part of this group. * {@link ol.layer.Layer layers} that are part of this group.
* @observable * @observable
* @api stable * @api stable
*/ */
ol.layer.Group.prototype.getLayers = function() { ol.layer.Group.prototype.getLayers = function() {
return /** @type {ol.Collection.<ol.layer.Base>|undefined} */ (this.get( return /** @type {!ol.Collection.<ol.layer.Base>} */ (this.get(
ol.layer.GroupProperty.LAYERS)); ol.layer.GroupProperty.LAYERS));
}; };
goog.exportProperty( goog.exportProperty(
@@ -161,7 +161,7 @@ goog.exportProperty(
/** /**
* @param {ol.Collection.<ol.layer.Base>|undefined} layers Collection of * @param {!ol.Collection.<ol.layer.Base>} layers Collection of
* {@link ol.layer.Layer layers} that are part of this group. * {@link ol.layer.Layer layers} that are part of this group.
* @observable * @observable
* @api stable * @api stable
+3 -9
View File
@@ -495,7 +495,6 @@ ol.Map.prototype.addInteraction = function(interaction) {
*/ */
ol.Map.prototype.addLayer = function(layer) { ol.Map.prototype.addLayer = function(layer) {
var layers = this.getLayerGroup().getLayers(); var layers = this.getLayerGroup().getLayers();
goog.asserts.assert(goog.isDef(layers));
layers.push(layer); layers.push(layer);
}; };
@@ -703,16 +702,12 @@ goog.exportProperty(
/** /**
* Get the collection of layers associated with this map. * Get the collection of layers associated with this map.
* @return {ol.Collection.<ol.layer.Base>|undefined} Layers. * @return {!ol.Collection.<ol.layer.Base>} Layers.
* @api stable * @api stable
*/ */
ol.Map.prototype.getLayers = function() { ol.Map.prototype.getLayers = function() {
var layerGroup = this.getLayerGroup(); var layers = this.getLayerGroup().getLayers();
if (goog.isDef(layerGroup)) { return layers;
return layerGroup.getLayers();
} else {
return undefined;
}
}; };
@@ -1147,7 +1142,6 @@ ol.Map.prototype.removeInteraction = function(interaction) {
*/ */
ol.Map.prototype.removeLayer = function(layer) { ol.Map.prototype.removeLayer = function(layer) {
var layers = this.getLayerGroup().getLayers(); var layers = this.getLayerGroup().getLayers();
goog.asserts.assert(goog.isDef(layers));
return layers.remove(layer); return layers.remove(layer);
}; };