Skip to content
Snippets Groups Projects
Commit 55dc4ee0 authored by Tor-Einar Skog's avatar Tor-Einar Skog
Browse files

Get title and abstract from GeoServer WMS (one level below Mapserver's)

parent c8093b93
Branches
No related tags found
No related merge requests found
...@@ -182,7 +182,9 @@ async function initGridMap(inputModelId, wmsURL, mapAttribution) { ...@@ -182,7 +182,9 @@ async function initGridMap(inputModelId, wmsURL, mapAttribution) {
// Get layers from WMS service // Get layers from WMS service
let parser = new ol.format.WMSCapabilities(); let parser = new ol.format.WMSCapabilities();
//console.info(mapserverURL + modelId + "?service=WMS&version=1.3.0&request=GetCapabilities"); //console.info(mapserverURL + modelId + "?service=WMS&version=1.3.0&request=GetCapabilities");
let response = await fetch(wmsURL + "?service=WMS&version=1.3.0&request=GetCapabilities&language=" + settings.currentLanguage); //let response = await fetch(wmsURL + "?service=WMS&version=1.3.0&request=GetCapabilities&language=" + settings.currentLanguage);
let response = await fetch(wmsURL + "?service=WMS&request=GetCapabilities");
//console.info(wmsURL + "?service=WMS&request=GetCapabilities&language=en");
//console.info(response.status); // Response is 200 even if a model doesn't exist on the mapserver //console.info(response.status); // Response is 200 even if a model doesn't exist on the mapserver
let txt = await response.text(); let txt = await response.text();
...@@ -202,12 +204,24 @@ async function initGridMap(inputModelId, wmsURL, mapAttribution) { ...@@ -202,12 +204,24 @@ async function initGridMap(inputModelId, wmsURL, mapAttribution) {
WMSLayers = WMSLayers[0].Layer; WMSLayers = WMSLayers[0].Layer;
} }
//console.info(WMSLayers); //console.info(WMSLayers);
//console.info(capabilities);
document.getElementById("modelTitle").innerHTML = capabilities.Service.Title; // Get title and abstract. Could be either at top level or the level below
if(capabilities.Service.Abstract != undefined) let modelTitle = capabilities.Service.Title;
let modelAbstract = undefined;
if(modelTitle != undefined && modelTitle.trim() != "")
{
modelAbstract = capabilities.Service.Abstract;
}
else
{
modelTitle = capabilities.Capability.Layer.Layer[0].Title;
modelAbstract = capabilities.Capability.Layer.Layer[0].Abstract;
}
document.getElementById("modelTitle").innerHTML = modelTitle;
if(modelAbstract != undefined)
{ {
// Placing the sections above/below the map // Placing the sections above/below the map
let el = new DOMParser().parseFromString(capabilities.Service.Abstract.replaceAll("\n\n",""),"text/html"); let el = new DOMParser().parseFromString(modelAbstract.replaceAll("\n\n",""),"text/html");
let preamble = el.getElementById("preamble") != null ? el.getElementById("preamble") : el; let preamble = el.getElementById("preamble") != null ? el.getElementById("preamble") : el;
document.getElementById("modelAbstractPreamble").innerHTML = new XMLSerializer().serializeToString(preamble); document.getElementById("modelAbstractPreamble").innerHTML = new XMLSerializer().serializeToString(preamble);
let body = el.getElementById("body") != null ? el.getElementById("body") : null; let body = el.getElementById("body") != null ? el.getElementById("body") : null;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment