Add maxZoom option to BingMaps
This commit is contained in:
@@ -42,6 +42,7 @@
|
||||
<h4 id="title">Bing Maps example</h4>
|
||||
<p id="shortdesc">Example of a Bing Maps layer.</p>
|
||||
<div id="docs">
|
||||
<p>When the Bing Maps tile service doesn't have tiles for a given resolution and region it returns "placeholder" tiles indicating that. Zoom the map beyond level 19 to see the "placeholder" tiles. If you want OpenLayers to display stretched tiles in place of "placeholder" tiles beyond zoom level 19 then set <code>maxZoom</code> to <code>19</code> in the options passed to <code>ol.source.BingMaps</code>.</p>
|
||||
<p>See the <a href="bing-maps.js" target="_blank">bing-maps.js source</a> to see how this is done.</p>
|
||||
</div>
|
||||
<div id="tags">bing, bing-maps</div>
|
||||
|
||||
@@ -20,6 +20,9 @@ for (i = 0, ii = styles.length; i < ii; ++i) {
|
||||
source: new ol.source.BingMaps({
|
||||
key: 'Ak-dzM4wZjSqTlzveKz5u0d4IQ4bRzVI309GxmkgSVr1ewS6iPSrOvOKhA-CJlm3',
|
||||
imagerySet: styles[i]
|
||||
// use maxZoom 19 to see stretched tiles instead of the BingMaps
|
||||
// "no photos at this zoom level" tiles
|
||||
// maxZoom: 19
|
||||
})
|
||||
}));
|
||||
}
|
||||
|
||||
@@ -3101,6 +3101,7 @@ olx.FeatureOverlayOptions.prototype.style;
|
||||
* @typedef {{culture: (string|undefined),
|
||||
* key: string,
|
||||
* imagerySet: string,
|
||||
* maxZoom: (number|undefined),
|
||||
* tileLoadFunction: (ol.TileLoadFunctionType|undefined)}}
|
||||
* @api
|
||||
*/
|
||||
@@ -3131,6 +3132,15 @@ olx.source.BingMapsOptions.prototype.key;
|
||||
olx.source.BingMapsOptions.prototype.imagerySet;
|
||||
|
||||
|
||||
/**
|
||||
* Max zoom. Default is what's advertized by the BingMaps service (`21`
|
||||
* currently).
|
||||
* @type {number|undefined}
|
||||
* @api
|
||||
*/
|
||||
olx.source.BingMapsOptions.prototype.maxZoom;
|
||||
|
||||
|
||||
/**
|
||||
* Optional function to load a tile given a URL.
|
||||
* @type {ol.TileLoadFunctionType|undefined}
|
||||
|
||||
@@ -42,6 +42,12 @@ ol.source.BingMaps = function(options) {
|
||||
*/
|
||||
this.culture_ = goog.isDef(options.culture) ? options.culture : 'en-us';
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {number}
|
||||
*/
|
||||
this.maxZoom_ = goog.isDef(options.maxZoom) ? options.maxZoom : -1;
|
||||
|
||||
var protocol = ol.IS_HTTPS ? 'https:' : 'http:';
|
||||
var uri = new goog.Uri(
|
||||
protocol + '//dev.virtualearth.net/REST/v1/Imagery/Metadata/' +
|
||||
@@ -87,13 +93,14 @@ ol.source.BingMaps.prototype.handleImageryMetadataResponse =
|
||||
var brandLogoUri = response.brandLogoUri;
|
||||
//var copyright = response.copyright; // FIXME do we need to display this?
|
||||
var resource = response.resourceSets[0].resources[0];
|
||||
|
||||
goog.asserts.assert(resource.imageWidth == resource.imageHeight);
|
||||
var maxZoom = this.maxZoom_ == -1 ? resource.zoomMax : this.maxZoom_;
|
||||
|
||||
var sourceProjection = this.getProjection();
|
||||
var tileGrid = new ol.tilegrid.XYZ({
|
||||
extent: ol.tilegrid.extentFromProjection(sourceProjection),
|
||||
minZoom: resource.zoomMin,
|
||||
maxZoom: resource.zoomMax,
|
||||
maxZoom: maxZoom,
|
||||
tileSize: resource.imageWidth
|
||||
});
|
||||
this.tileGrid = tileGrid;
|
||||
@@ -141,7 +148,7 @@ ol.source.BingMaps.prototype.handleImageryMetadataResponse =
|
||||
imageryProvider.coverageAreas,
|
||||
function(coverageArea) {
|
||||
var minZ = coverageArea.zoomMin;
|
||||
var maxZ = coverageArea.zoomMax;
|
||||
var maxZ = Math.min(coverageArea.zoomMax, maxZoom);
|
||||
var bbox = coverageArea.bbox;
|
||||
var epsg4326Extent = [bbox[1], bbox[0], bbox[3], bbox[2]];
|
||||
var extent = ol.extent.applyTransform(
|
||||
|
||||
Reference in New Issue
Block a user