Fix vector tile rotation on HiDPI devices

This commit is contained in:
Andreas Hocevar
2016-08-27 19:58:38 +02:00
parent fe6fe702b2
commit cb7c15c767
9 changed files with 52 additions and 11 deletions

View File

@@ -242,10 +242,14 @@ ol.source.Tile.prototype.getTileCacheForProjection = function(projection) {
/**
* @param {number} pixelRatio Pixel ratio.
* Get the tile pixel ratio for this source. Subclasses may override this
* method, which is meant to return a supported pixel ratio that matches the
* provided `opt_pixelRatio` as close as possible. When no `opt_pixelRatio` is
* provided, it is meant to return `this.tilePixelRatio_`.
* @param {number=} opt_pixelRatio Pixel ratio.
* @return {number} Tile pixel ratio.
*/
ol.source.Tile.prototype.getTilePixelRatio = function(pixelRatio) {
ol.source.Tile.prototype.getTilePixelRatio = function(opt_pixelRatio) {
return this.tilePixelRatio_;
};

View File

@@ -121,7 +121,7 @@ ol.source.TileArcGISRest.prototype.getRequestUrl_ = function(tileCoord, tileSize
* @inheritDoc
*/
ol.source.TileArcGISRest.prototype.getTilePixelRatio = function(pixelRatio) {
return pixelRatio;
return /** @type {number} */ (pixelRatio);
};

View File

@@ -271,7 +271,8 @@ ol.source.TileWMS.prototype.getRequestUrl_ = function(tileCoord, tileSize, tileE
* @inheritDoc
*/
ol.source.TileWMS.prototype.getTilePixelRatio = function(pixelRatio) {
return (!this.hidpi_ || this.serverType_ === undefined) ? 1 : pixelRatio;
return (!this.hidpi_ || this.serverType_ === undefined) ? 1 :
/** @type {number} */ (pixelRatio);
};

View File

@@ -104,12 +104,22 @@ ol.source.VectorTile.prototype.getTile = function(z, x, y, pixelRatio, projectio
};
/**
* @inheritDoc
*/
ol.source.VectorTile.prototype.getTilePixelRatio = function(opt_pixelRatio) {
return opt_pixelRatio == undefined ?
ol.source.UrlTile.prototype.getTilePixelRatio.call(this, opt_pixelRatio) :
opt_pixelRatio;
};
/**
* @inheritDoc
*/
ol.source.VectorTile.prototype.getTilePixelSize = function(z, pixelRatio, projection) {
var tileSize = ol.size.toSize(this.tileGrid.getTileSize(z));
return [tileSize[0] * pixelRatio, tileSize[1] * pixelRatio];
return [Math.round(tileSize[0] * pixelRatio), Math.round(tileSize[1] * pixelRatio)];
};