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

Add layer legend

parent a8957669
Branches
Tags
No related merge requests found
...@@ -17,7 +17,7 @@ let WMSLayersDateBucket = {}; ...@@ -17,7 +17,7 @@ let WMSLayersDateBucket = {};
let map = undefined; let map = undefined;
let popup = undefined; let popup = undefined;
function switchLayer(dayIndex) async function switchLayer(dayIndex)
{ {
currentTimestamp = timestamps[dayIndex]; currentTimestamp = timestamps[dayIndex];
currentLayer = WMSLayersDateBucket[currentTimestamp][currentParameter]; currentLayer = WMSLayersDateBucket[currentTimestamp][currentParameter];
...@@ -26,6 +26,14 @@ function switchLayer(dayIndex) ...@@ -26,6 +26,14 @@ function switchLayer(dayIndex)
for(let i=0;i<layers.length;i++) for(let i=0;i<layers.length;i++)
{ {
layers[i].setVisible(i==currentLayerOrdering); layers[i].setVisible(i==currentLayerOrdering);
if(layers[i].getVisible())
{
document.getElementById("layerLegendImg").src=currentLayer.Style[0].LegendURL[0].OnlineResource;
console.info(currentLayer.Style[0].LegendURL[0].OnlineResource);
// Get the legend!
//let legendURL = layers[i].getSource().getLegendUrl(map.getView().getResolution());
//console.info(legendURL);
}
} }
setCurrentDate(dayIndex); setCurrentDate(dayIndex);
} }
...@@ -63,7 +71,7 @@ async function initSlidingMap(lonLat, zoomLevel, mapAttribution) { ...@@ -63,7 +71,7 @@ async function initSlidingMap(lonLat, zoomLevel, mapAttribution) {
let WMSLayers = capabilities.Capability.Layer.Layer; let WMSLayers = capabilities.Capability.Layer.Layer;
document.getElementById("modelTitle").innerHTML = capabilities.Service.Title; document.getElementById("modelTitle").innerHTML = capabilities.Service.Title;
document.getElementById("modelAbstract").innerHTML = capabilities.Service.Abstract.replaceAll("\n\n","XXX"); document.getElementById("modelAbstract").innerHTML = capabilities.Service.Abstract.replaceAll("\n\n","XXX");
//console.info(capabilities.Service.Abstract); console.info(capabilities);
// Analyze and organize layers // Analyze and organize layers
// First dimension: Time // First dimension: Time
...@@ -125,12 +133,7 @@ async function initSlidingMap(lonLat, zoomLevel, mapAttribution) { ...@@ -125,12 +133,7 @@ async function initSlidingMap(lonLat, zoomLevel, mapAttribution) {
} }
} }
let range = document.getElementById("layerDateRange");
range.min = 0;
range.max = timestamps.length -1;
range.value = todayLayerIndex;
setCurrentDate(todayLayerIndex);
switchLayer(todayLayerIndex);
//console.info(WMSLayersDateBucket); //console.info(WMSLayersDateBucket);
...@@ -151,6 +154,13 @@ async function initSlidingMap(lonLat, zoomLevel, mapAttribution) { ...@@ -151,6 +154,13 @@ async function initSlidingMap(lonLat, zoomLevel, mapAttribution) {
}); });
map.setView(view); map.setView(view);
let range = document.getElementById("layerDateRange");
range.min = 0;
range.max = timestamps.length -1;
range.value = todayLayerIndex;
setCurrentDate(todayLayerIndex);
switchLayer(todayLayerIndex);
popup = new ol.Overlay({ popup = new ol.Overlay({
element: document.getElementById('popup') element: document.getElementById('popup')
}); });
......
...@@ -32,6 +32,9 @@ ...@@ -32,6 +32,9 @@
</div> </div>
<div class="form-group" id="paramselector" style="position: absolute; right: 20px; bottom: 20px; background-color: white; z-index: 1000;padding: 15px; border-radius: 15px;"> <div class="form-group" id="paramselector" style="position: absolute; right: 20px; bottom: 20px; background-color: white; z-index: 1000;padding: 15px; border-radius: 15px;">
</div> </div>
<div id="layerLegend" style="position: absolute; right: 20px; top: 20px; background-color: white; z-index: 1000;padding: 15px; border-radius: 15px;">
<img id="layerLegendImg" src=""/>
</div>
</div> </div>
<div id="popup" title="Location details"></div> <div id="popup" title="Location details"></div>
<div class="col-md-12"> <div class="col-md-12">
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment