Optionally enable hidpi support for Bing
This commit is contained in:
@@ -4034,6 +4034,7 @@ olx.source;
|
|||||||
/**
|
/**
|
||||||
* @typedef {{cacheSize: (number|undefined),
|
* @typedef {{cacheSize: (number|undefined),
|
||||||
* culture: (string|undefined),
|
* culture: (string|undefined),
|
||||||
|
* hidpi: (boolean|undefined),
|
||||||
* key: string,
|
* key: string,
|
||||||
* imagerySet: string,
|
* imagerySet: string,
|
||||||
* maxZoom: (number|undefined),
|
* maxZoom: (number|undefined),
|
||||||
@@ -4052,6 +4053,14 @@ olx.source.BingMapsOptions;
|
|||||||
olx.source.BingMapsOptions.prototype.cacheSize;
|
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`.
|
* Culture code. Default is `en-us`.
|
||||||
* @type {string|undefined}
|
* @type {string|undefined}
|
||||||
|
|||||||
@@ -34,6 +34,12 @@ ol.source.BingMaps = function(options) {
|
|||||||
wrapX: options.wrapX !== undefined ? options.wrapX : true
|
wrapX: options.wrapX !== undefined ? options.wrapX : true
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @private
|
||||||
|
* @type {boolean}
|
||||||
|
*/
|
||||||
|
this.hidpi_ = options.hidpi !== undefined ? options.hidpi : false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
* @type {string}
|
* @type {string}
|
||||||
@@ -142,6 +148,7 @@ ol.source.BingMaps.prototype.handleImageryMetadataResponse = function(response)
|
|||||||
this.tileGrid = tileGrid;
|
this.tileGrid = tileGrid;
|
||||||
|
|
||||||
var culture = this.culture_;
|
var culture = this.culture_;
|
||||||
|
var hidpi = this.hidpi_;
|
||||||
this.tileUrlFunction = ol.TileUrlFunction.createFromTileUrlFunctions(
|
this.tileUrlFunction = ol.TileUrlFunction.createFromTileUrlFunctions(
|
||||||
resource.imageUrlSubdomains.map(function(subdomain) {
|
resource.imageUrlSubdomains.map(function(subdomain) {
|
||||||
var quadKeyTileCoord = [0, 0, 0];
|
var quadKeyTileCoord = [0, 0, 0];
|
||||||
@@ -164,7 +171,11 @@ ol.source.BingMaps.prototype.handleImageryMetadataResponse = function(response)
|
|||||||
} else {
|
} else {
|
||||||
ol.tilecoord.createOrUpdate(tileCoord[0], tileCoord[1],
|
ol.tilecoord.createOrUpdate(tileCoord[0], tileCoord[1],
|
||||||
-tileCoord[2] - 1, quadKeyTileCoord);
|
-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));
|
quadKeyTileCoord));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user