add numZoomLevels and maxResolution properties to the TileLayer
This commit is contained in:
@@ -50,6 +50,18 @@ ol.layer.TileLayer = function() {
|
||||
*/
|
||||
this.tileOriginCorner_ = 'bl';
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {number|undefined}
|
||||
*/
|
||||
this.maxResolution_ = undefined;
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {number|undefined}
|
||||
*/
|
||||
this.numZoomLevels_ = undefined;
|
||||
|
||||
/**
|
||||
* @protected
|
||||
* @type {Array.<number>}
|
||||
@@ -121,6 +133,20 @@ ol.layer.TileLayer.prototype.getTileOrigin = function() {
|
||||
return null;
|
||||
};
|
||||
|
||||
/**
|
||||
* Get layer resolutions. Return null if the layer has no resolutions.
|
||||
* @return {Array.<number>}
|
||||
*/
|
||||
ol.layer.TileLayer.prototype.getResolutions = function() {
|
||||
if (goog.isNull(this.resolutions_) && goog.isDef(this.maxResolution_)) {
|
||||
this.resolutions_ = [];
|
||||
for (var i = 0; i < this.numZoomLevels_; i++) {
|
||||
this.resolutions_[i] = this.maxResolution_ / Math.pow(2, i);
|
||||
}
|
||||
}
|
||||
return this.resolutions_;
|
||||
};
|
||||
|
||||
/**
|
||||
* Set layer projection.
|
||||
* @param {ol.Projection} projection
|
||||
@@ -165,6 +191,22 @@ ol.layer.TileLayer.prototype.setTileOriginCorner = function(tileOriginCorner) {
|
||||
this.tileOriginCorner_ = tileOriginCorner;
|
||||
};
|
||||
|
||||
/**
|
||||
* Set maximum resolution.
|
||||
* @param {number} maxResolution
|
||||
*/
|
||||
ol.layer.TileLayer.prototype.setMaxResolution = function(maxResolution) {
|
||||
this.maxResolution_ = maxResolution;
|
||||
};
|
||||
|
||||
/**
|
||||
* Set the number of zoom levels.
|
||||
* @param {number} numZoomLevels
|
||||
*/
|
||||
ol.layer.TileLayer.prototype.setNumZoomLevels = function(numZoomLevels) {
|
||||
this.numZoomLevels_ = numZoomLevels;
|
||||
};
|
||||
|
||||
/**
|
||||
* Set resolutions for the layer.
|
||||
* @param {Array.<number>} resolutions
|
||||
|
||||
Reference in New Issue
Block a user