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

View File

@@ -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.<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.
* @observable
* @api stable
*/
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));
};
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.
* @observable
* @api stable

View File

@@ -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.<ol.layer.Base>|undefined} Layers.
* @return {!ol.Collection.<ol.layer.Base>} 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);
};