more "setters should not return this" changes + warning fixes

This commit is contained in:
Éric Lemoine
2012-06-20 11:21:19 +02:00
parent 27305925ff
commit e995ffea89
2 changed files with 22 additions and 30 deletions

View File

@@ -31,9 +31,9 @@ ol.map = function(opt_arg){
var userProjection;
/** @type {ol.Bounds|undefined} */
var maxExtent;
/** @type {array|undefined} */
/** @type {Array.<number>|undefined} */
var resolutions;
/** @type {array|undefined} */
/** @type {Array|undefined} */
var layers;
if (arguments.length == 1) {
@@ -90,7 +90,8 @@ ol.map = function(opt_arg){
*/
ol.Map.prototype.center = function(opt_arg) {
if (arguments.length == 1 && goog.isDef(opt_arg)) {
return this.setCenter(ol.loc(opt_arg));
this.setCenter(ol.loc(opt_arg));
return this;
} else {
return this.getCenter();
}
@@ -102,7 +103,8 @@ ol.Map.prototype.center = function(opt_arg) {
*/
ol.Map.prototype.projection = function(opt_arg) {
if (arguments.length == 1 && goog.isDef(opt_arg)) {
return this.setProjection(ol.projection(opt_arg));
this.setProjection(ol.projection(opt_arg));
return this;
} else {
return this.getProjection();
}
@@ -114,7 +116,8 @@ ol.Map.prototype.projection = function(opt_arg) {
*/
ol.Map.prototype.userProjection = function(opt_arg) {
if (arguments.length == 1 && goog.isDef(opt_arg)) {
return this.setUserProjection(ol.projection(opt_arg));
this.setUserProjection(ol.projection(opt_arg));
return this;
} else {
return this.getUserProjection();
}
@@ -126,7 +129,8 @@ ol.Map.prototype.userProjection = function(opt_arg) {
*/
ol.Map.prototype.zoom = function(opt_arg) {
if (arguments.length == 1 && goog.isDef(opt_arg)) {
return this.setZoom(opt_arg);
this.setZoom(opt_arg);
return this;
} else {
return this.getZoom();
}
@@ -138,7 +142,8 @@ ol.Map.prototype.zoom = function(opt_arg) {
*/
ol.Map.prototype.numZoomLevels = function(opt_arg) {
if (arguments.length == 1 && goog.isDef(opt_arg)) {
return this.setNumZoomLevels(opt_arg);
this.setNumZoomLevels(opt_arg);
return this;
} else {
return this.getNumZoomLevels();
}
@@ -150,7 +155,8 @@ ol.Map.prototype.numZoomLevels = function(opt_arg) {
*/
ol.Map.prototype.resolutions = function(opt_arg) {
if (arguments.length == 1 && goog.isDef(opt_arg)) {
return this.setResolutions(opt_arg);
this.setResolutions(opt_arg);
return this;
} else {
return this.getResolutions();
}
@@ -162,7 +168,8 @@ ol.Map.prototype.resolutions = function(opt_arg) {
*/
ol.Map.prototype.layers = function(opt_arg) {
if (arguments.length == 1 && goog.isDef(opt_arg)) {
return this.setLayers(opt_arg);
this.setLayers(opt_arg);
return this;
} else {
return this.getLayers();
}
@@ -170,11 +177,12 @@ ol.Map.prototype.layers = function(opt_arg) {
/**
* @param {Array=} opt_arg
* @returns {ol.Map|ol.Bounds|undefined} Map max extent.
* @returns {ol.Map|ol.UnreferencedBounds|undefined} Map max extent.
*/
ol.Map.prototype.maxExtent = function(opt_arg) {
if (arguments.length == 1 && goog.isDef(opt_arg)) {
return this.setMaxExtent(ol.bounds(opt_arg));
this.setMaxExtent(ol.bounds(opt_arg));
return this;
} else {
return this.getMaxExtent();
}

View File

@@ -30,7 +30,7 @@ ol.Map = function() {
/**
* @private
* @type {number}
* @type {number|undefined}
*/
this.zoom_ = undefined;
@@ -97,7 +97,7 @@ ol.Map.prototype.getUserProjection = function() {
/**
* @return {number} Zoom.
* @return {number|undefined} Zoom.
*/
ol.Map.prototype.getZoom = function() {
return this.zoom_;
@@ -129,7 +129,7 @@ ol.Map.prototype.getLayers = function() {
/**
* @return {ol.Bounds} the maxExtent for the map
* @return {ol.UnreferencedBounds} the maxExtent for the map
*/
ol.Map.prototype.getMaxExtent = function() {
if (goog.isDefAndNotNull(this.maxExtent_)) {
@@ -147,78 +147,62 @@ ol.Map.prototype.getMaxExtent = function() {
/**
* @param {ol.Loc} center Center.
* @return {ol.Map} This.
*/
ol.Map.prototype.setCenter = function(center) {
this.center_ = center;
return this;
};
/**
* @param {ol.Projection} projection Projection.
* @return {ol.Map} This.
*/
ol.Map.prototype.setProjection = function(projection) {
this.projection_ = projection;
return this;
};
/**
* @param {ol.Projection} userProjection set the user projection.
* @return {ol.Map} This.
*/
ol.Map.prototype.setUserProjection = function(userProjection) {
this.userProjection_ = userProjection;
return this;
};
/**
* @param {number} zoom Zoom.
* @return {ol.Map} This.
*/
ol.Map.prototype.setZoom = function(zoom) {
this.zoom_ = zoom;
return this;
};
/**
* @param {number} nZoom Zoom.
* @return {ol.Map} This.
*/
ol.Map.prototype.setNumZoomLevels = function(nZoom) {
this.numZoomLevels_ = nZoom;
return this;
};
/**
* @param {Array} resolutions the map resolutions if set on the map
* @return {ol.Map} This.
*/
ol.Map.prototype.setResolutions = function(resolutions) {
this.resolutions_ = resolutions;
return this;
};
/**
* @param {Array} layers the layers set on the map
* @return {ol.Map} This.
*/
ol.Map.prototype.setLayers = function(layers) {
this.layers_ = layers;
return this;
};
/**
* @param {ol.Bounds} extent the maxExtent for the map
* @return {ol.Map} This.
*/
ol.Map.prototype.setMaxExtent = function(extent) {
this.maxExtent_ = extent;
return this;
};
/**