From d52b3715d983cafe0e174c6bd0d0f1c3f1729cce Mon Sep 17 00:00:00 2001 From: Andreas Hocevar Date: Mon, 7 Nov 2016 19:09:12 +0100 Subject: [PATCH] Fix tile size and pixel ratio --- src/ol/source/bingmaps.js | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/ol/source/bingmaps.js b/src/ol/source/bingmaps.js index 07b0fd8804..a236388f40 100644 --- a/src/ol/source/bingmaps.js +++ b/src/ol/source/bingmaps.js @@ -23,6 +23,12 @@ goog.require('ol.tilegrid'); */ ol.source.BingMaps = function(options) { + /** + * @private + * @type {boolean} + */ + this.hidpi_ = options.hidpi !== undefined ? options.hidpi : false; + ol.source.TileImage.call(this, { cacheSize: options.cacheSize, crossOrigin: 'anonymous', @@ -31,15 +37,10 @@ ol.source.BingMaps = function(options) { reprojectionErrorThreshold: options.reprojectionErrorThreshold, state: ol.source.State.LOADING, tileLoadFunction: options.tileLoadFunction, + tilePixelRatio: this.hidpi_ ? 2 : 1, wrapX: options.wrapX !== undefined ? options.wrapX : true }); - /** - * @private - * @type {boolean} - */ - this.hidpi_ = options.hidpi !== undefined ? options.hidpi : false; - /** * @private * @type {string} @@ -143,7 +144,7 @@ ol.source.BingMaps.prototype.handleImageryMetadataResponse = function(response) extent: extent, minZoom: resource.zoomMin, maxZoom: maxZoom, - tileSize: tileSize + tileSize: tileSize / this.getTilePixelRatio() }); this.tileGrid = tileGrid; @@ -172,7 +173,7 @@ ol.source.BingMaps.prototype.handleImageryMetadataResponse = function(response) ol.tilecoord.createOrUpdate(tileCoord[0], tileCoord[1], -tileCoord[2] - 1, quadKeyTileCoord); var url = imageUrl; - if (hidpi && pixelRatio >= 2) { + if (hidpi) { url += '&dpi=d1&device=mobile'; } return url.replace('{quadkey}', ol.tilecoord.quadKey(