diff --git a/externs/olx.js b/externs/olx.js index ee532d33a5..8a0699b9f2 100644 --- a/externs/olx.js +++ b/externs/olx.js @@ -4034,6 +4034,7 @@ olx.source; /** * @typedef {{cacheSize: (number|undefined), * culture: (string|undefined), + * hidpi: (boolean|undefined), * key: string, * imagerySet: string, * maxZoom: (number|undefined), @@ -4052,6 +4053,14 @@ olx.source.BingMapsOptions; olx.source.BingMapsOptions.prototype.cacheSize; +/** + * If device pixelRatio is >= 2, hidpi tiles will be requested. Default is `false`. + * @type {boolean|undefined} + * @api + */ +olx.source.BingMapsOptions.prototype.hidpi; + + /** * Culture code. Default is `en-us`. * @type {string|undefined} diff --git a/src/ol/source/bingmaps.js b/src/ol/source/bingmaps.js index ec42b10232..07b0fd8804 100644 --- a/src/ol/source/bingmaps.js +++ b/src/ol/source/bingmaps.js @@ -34,6 +34,12 @@ ol.source.BingMaps = function(options) { wrapX: options.wrapX !== undefined ? options.wrapX : true }); + /** + * @private + * @type {boolean} + */ + this.hidpi_ = options.hidpi !== undefined ? options.hidpi : false; + /** * @private * @type {string} @@ -142,6 +148,7 @@ ol.source.BingMaps.prototype.handleImageryMetadataResponse = function(response) this.tileGrid = tileGrid; var culture = this.culture_; + var hidpi = this.hidpi_; this.tileUrlFunction = ol.TileUrlFunction.createFromTileUrlFunctions( resource.imageUrlSubdomains.map(function(subdomain) { var quadKeyTileCoord = [0, 0, 0]; @@ -164,7 +171,11 @@ ol.source.BingMaps.prototype.handleImageryMetadataResponse = function(response) } else { ol.tilecoord.createOrUpdate(tileCoord[0], tileCoord[1], -tileCoord[2] - 1, quadKeyTileCoord); - return imageUrl.replace('{quadkey}', ol.tilecoord.quadKey( + var url = imageUrl; + if (hidpi && pixelRatio >= 2) { + url += '&dpi=d1&device=mobile'; + } + return url.replace('{quadkey}', ol.tilecoord.quadKey( quadKeyTileCoord)); } });