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

@@ -12,8 +12,10 @@ fetch('data/WMTSCapabilities.xml').then(function(response) {
return response.text();
}).then(function(text) {
var result = parser.read(text);
var options = ol.source.WMTS.optionsFromCapabilities(result,
{layer: 'layer-7328', matrixSet: 'EPSG:3857'});
var options = ol.source.WMTS.optionsFromCapabilities(result, {
layer: 'layer-7328',
matrixSet: 'EPSG:3857'
});
map = new ol.Map({
layers: [
@@ -23,7 +25,7 @@ fetch('data/WMTSCapabilities.xml').then(function(response) {
}),
new ol.layer.Tile({
opacity: 1,
source: new ol.source.WMTS(options)
source: new ol.source.WMTS(/** @type {!olx.source.WMTSOptions} */ (options))
})
],
target: 'map',