diff --git a/src/ol/source/bingmapssource.js b/src/ol/source/bingmapssource.js index 975c471d9f..ea61cf5f1d 100644 --- a/src/ol/source/bingmapssource.js +++ b/src/ol/source/bingmapssource.js @@ -115,37 +115,40 @@ ol.source.BingMaps.prototype.handleImageryMetadataResponse = }); }))); - var transform = ol.proj.getTransformFromProjections( - ol.proj.get('EPSG:4326'), this.getProjection()); - var attributions = goog.array.map( - resource.imageryProviders, - function(imageryProvider) { - var html = imageryProvider.attribution; - /** @type {Object.>} */ - var tileRanges = {}; - goog.array.forEach( - imageryProvider.coverageAreas, - function(coverageArea) { - var minZ = coverageArea.zoomMin; - var maxZ = coverageArea.zoomMax; - var bbox = coverageArea.bbox; - var epsg4326Extent = [bbox[1], bbox[0], bbox[3], bbox[2]]; - var extent = ol.extent.transform(epsg4326Extent, transform); - var tileRange, z, zKey; - for (z = minZ; z <= maxZ; ++z) { - zKey = z.toString(); - tileRange = tileGrid.getTileRangeForExtentAndZ(extent, z); - if (zKey in tileRanges) { - tileRanges[zKey].push(tileRange); - } else { - tileRanges[zKey] = [tileRange]; + if (resource.imageryProviders) { + var transform = ol.proj.getTransformFromProjections( + ol.proj.get('EPSG:4326'), this.getProjection()); + + var attributions = goog.array.map( + resource.imageryProviders, + function(imageryProvider) { + var html = imageryProvider.attribution; + /** @type {Object.>} */ + var tileRanges = {}; + goog.array.forEach( + imageryProvider.coverageAreas, + function(coverageArea) { + var minZ = coverageArea.zoomMin; + var maxZ = coverageArea.zoomMax; + var bbox = coverageArea.bbox; + var epsg4326Extent = [bbox[1], bbox[0], bbox[3], bbox[2]]; + var extent = ol.extent.transform(epsg4326Extent, transform); + var tileRange, z, zKey; + for (z = minZ; z <= maxZ; ++z) { + zKey = z.toString(); + tileRange = tileGrid.getTileRangeForExtentAndZ(extent, z); + if (zKey in tileRanges) { + tileRanges[zKey].push(tileRange); + } else { + tileRanges[zKey] = [tileRange]; + } } - } - }); - return new ol.Attribution({html: html, tileRanges: tileRanges}); - }); - attributions.push(ol.source.BingMaps.TOS_ATTRIBUTION); - this.setAttributions(attributions); + }); + return new ol.Attribution({html: html, tileRanges: tileRanges}); + }); + attributions.push(ol.source.BingMaps.TOS_ATTRIBUTION); + this.setAttributions(attributions); + } this.setLogo(brandLogoUri);