I'm having a some trouble understanding how to remove this layer on a timer the basic idea is to refresh the wms layer so from what I have looked at the best way is to remove it and add it again maybe using a extra parameters like date : Math.random(); but I'm stumped on removing the layer is it something like viewer.remove(radar, true); I guess I could use a code sample to understand it more. It would be great to get a sample so I could understand it.
Got it, one more problem is come up layer.alpha = 0.5;
is not working after I readd the layer? Am I doing something incorrectly or is there a way to default the layer alpha to .5?
function myTimer() {
imageryLayers.remove(layer);
imageryLayers.remove(warnings);
var layer = imageryLayers.addImageryProvider(new Cesium.WebMapServiceImageryProvider({
url : '//mesonet.agron.iastate.edu/cgi-bin/wms/nexrad/n0r.cgi?',
layers : 'nexrad-n0r',
parameters : {
transparent : true,
format : 'image/png',
mydata : Math.random()
}
}));
var warnings = imageryLayers.addImageryProvider(new Cesium.WebMapServiceImageryProvider({
url : '//mesonet.agron.iastate.edu/cgi-bin/wms/us/wwa.cgi?',
layers : 'warnings_p',
parameters : {
transparent : true,
format : 'image/png',
mydata : Math.random()
}
}));
layer.alpha = 0.5;
}
You have to be careful about the scope of your variables in Javascript. Moving var layer and var warnings outside of the function should solve the problem: