diff --git a/examples/bing-maps.html b/examples/bing-maps.html
index 33c8f9cbef..61cc800c46 100644
--- a/examples/bing-maps.html
+++ b/examples/bing-maps.html
@@ -42,6 +42,7 @@
Bing Maps example
Example of a Bing Maps layer.
+
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 maxZoom to 19 in the options passed to ol.source.BingMaps.
See the bing-maps.js source to see how this is done.
bing, bing-maps
diff --git a/examples/bing-maps.js b/examples/bing-maps.js
index 7b0a8e61e8..556076c7f3 100644
--- a/examples/bing-maps.js
+++ b/examples/bing-maps.js
@@ -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
})
}));
}
diff --git a/externs/olx.js b/externs/olx.js
index 056f68e92a..a46aa56d57 100644
--- a/externs/olx.js
+++ b/externs/olx.js
@@ -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}
diff --git a/src/ol/source/bingmapssource.js b/src/ol/source/bingmapssource.js
index 12e3b8dda9..2670bab953 100644
--- a/src/ol/source/bingmapssource.js
+++ b/src/ol/source/bingmapssource.js
@@ -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(