diff --git a/spatial/static/spatial/js/gridmap.js b/spatial/static/spatial/js/gridmap.js index b4f9403fa4ce0e6b40ba15a3fb905406dc26381b..a2a9c3e0d94101c6293cccb9547ee16ae21b9c73 100644 --- a/spatial/static/spatial/js/gridmap.js +++ b/spatial/static/spatial/js/gridmap.js @@ -57,7 +57,7 @@ async function switchLayer(dayIndex) if(layers[i].getVisible()) { // See if there is a language specific legend available - if(currentLayer.Abstract != undefined) + if(currentLayer.Abstract != undefined && currentLayer.Abstract.trim() != "") { document.getElementById("layerLegend").innerHTML= getLegendHTML(currentLayer.Abstract); } @@ -189,6 +189,20 @@ async function initGridMap(inputModelId, wmsURL, mapAttribution) { //console.info(txt); let capabilities = parser.read(txt); let WMSLayers = capabilities.Capability.Layer.Layer; + + // Test: Are WMSLayers one level behind? + let testName = WMSLayers[0].Name; + let testNameParts = testName.split("."); + // The name must have 3 parts + // Part 1 of name must equal the model ID + // Part 3 must be a parseable date (YYYY-MM-DD) + if(testNameParts.length != 3 || testNameParts[0] != modelId || testNameParts[2].length != 10) + { + // This is not the layer we want, we must search one level deeper. + WMSLayers = WMSLayers[0].Layer; + } + //console.info(WMSLayers); + document.getElementById("modelTitle").innerHTML = capabilities.Service.Title; if(capabilities.Service.Abstract != undefined) {