Return null if the layer was not found in the WMTS capabilities

This commit is contained in:
Frederic Junod
2017-03-08 15:03:48 +01:00
parent cc13ca68fa
commit 2e22fce718
5 changed files with 23 additions and 8 deletions

View File

@@ -292,7 +292,7 @@ ol.source.WMTS.prototype.updateDimensions = function(dimensions) {
* - style - {string} The name of the style
* - format - {string} Image format for the layer. Default is the first
* format returned in the GetCapabilities response.
* @return {olx.source.WMTSOptions} WMTS source options object.
* @return {?olx.source.WMTSOptions} WMTS source options object or `null` if the layer was not found.
* @api
*/
ol.source.WMTS.optionsFromCapabilities = function(wmtsCap, config) {
@@ -300,6 +300,9 @@ ol.source.WMTS.optionsFromCapabilities = function(wmtsCap, config) {
var l = ol.array.find(layers, function(elt, index, array) {
return elt['Identifier'] == config['layer'];
});
if (l === null) {
return null;
}
var tileMatrixSets = wmtsCap['Contents']['TileMatrixSet'];
var idx, matrixSet, matrixLimits;
if (l['TileMatrixSetLink'].length > 1) {