From bc8ba5b73a3f79f3d745710bdd0e4095d7300a2a Mon Sep 17 00:00:00 2001 From: Oliver Jowett Date: Fri, 5 Aug 2016 01:18:23 +0100 Subject: [PATCH] Refresh the nexrad tiles every 5 mins. --- public_html/layers.js | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/public_html/layers.js b/public_html/layers.js index 28cd9e6..1a04475 100644 --- a/public_html/layers.js +++ b/public_html/layers.js @@ -66,17 +66,26 @@ function createBaseLayers() { } } - us.push(new ol.layer.Tile({ + var nexrad = new ol.layer.Tile({ name: 'nexrad', title: 'NEXRAD', type: 'overlay', - source: new ol.source.XYZ({ - url : 'http://mesonet{1-3}.agron.iastate.edu/cache/tile.py/1.0.0/nexrad-n0q-900913/{z}/{x}/{y}.png', - attributions: 'NEXRAD courtesy of IEM' - }), opacity: 0.5, visible: false - })); + }); + us.push(nexrad); + + var refreshNexrad = function() { + // re-build the source to force a refresh of the nexrad tiles + var now = new Date().getTime(); + nexrad.setSource(new ol.source.XYZ({ + url : 'http://mesonet{1-3}.agron.iastate.edu/cache/tile.py/1.0.0/nexrad-n0q-900913/{z}/{x}/{y}.png?_=' + now, + attributions: 'NEXRAD courtesy of IEM' + })); + }; + + refreshNexrad(); + window.setInterval(refreshNexrad, 5 * 60000); if (world.length > 0) { layers.push(new ol.layer.Group({