Refresh the nexrad tiles every 5 mins.

This commit is contained in:
Oliver Jowett 2016-08-05 01:18:23 +01:00
parent 8766a58811
commit bc8ba5b73a

View file

@ -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 <a href="http://mesonet.agron.iastate.edu/">IEM</a>'
}),
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 <a href="http://mesonet.agron.iastate.edu/">IEM</a>'
}));
};
refreshNexrad();
window.setInterval(refreshNexrad, 5 * 60000);
if (world.length > 0) {
layers.push(new ol.layer.Group({