Add ol.TileGrid.getZForResolution
This commit is contained in:
@@ -259,6 +259,30 @@ ol.TileGrid.prototype.getTileCoordResolution = function(tileCoord) {
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {number} resolution Resolution.
|
||||
* @return {number} Z.
|
||||
*/
|
||||
ol.TileGrid.prototype.getZForResolution = function(resolution) {
|
||||
var z;
|
||||
for (z = 0; z < this.numResolutions_; ++z) {
|
||||
if (this.resolutions_[z] == resolution) {
|
||||
return z;
|
||||
} else if (this.resolutions_[z] < resolution) {
|
||||
if (z === 0) {
|
||||
return z;
|
||||
} else if (resolution - this.resolutions_[z] <=
|
||||
this.resolutions_[z - 1] - resolution) {
|
||||
return z;
|
||||
} else {
|
||||
return z - 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
return this.numResolutions_ - 1;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param {ol.TileCoord} tileCoord Tile coordinate.
|
||||
* @param {function(number, ol.TileBounds): boolean} callback Callback.
|
||||
|
||||
Reference in New Issue
Block a user