Make ol.source.Tile#getTilePixelRatio work for all sources

Even for sources which serve dynamic tile sizes based on devicePixelRatio
This commit is contained in:
Petr Sloup
2015-12-28 10:48:09 +01:00
parent 28240adaf5
commit 767ac44e99
5 changed files with 21 additions and 31 deletions
+9 -3
View File
@@ -243,9 +243,10 @@ ol.source.Tile.prototype.getTileCacheForProjection = function(projection) {
/**
* @param {number} pixelRatio Pixel ratio.
* @return {number} Tile pixel ratio.
*/
ol.source.Tile.prototype.getTilePixelRatio = function() {
ol.source.Tile.prototype.getTilePixelRatio = function(pixelRatio) {
return this.tilePixelRatio_;
};
@@ -259,8 +260,13 @@ ol.source.Tile.prototype.getTilePixelRatio = function() {
ol.source.Tile.prototype.getTilePixelSize =
function(z, pixelRatio, projection) {
var tileGrid = this.getTileGridForProjection(projection);
return ol.size.scale(ol.size.toSize(tileGrid.getTileSize(z), this.tmpSize),
this.tilePixelRatio_, this.tmpSize);
var tilePixelRatio = this.getTilePixelRatio(pixelRatio);
var tileSize = ol.size.toSize(tileGrid.getTileSize(z), this.tmpSize);
if (tilePixelRatio == 1) {
return tileSize;
} else {
return ol.size.scale(tileSize, tilePixelRatio, this.tmpSize);
}
};