AnsweredAssumed Answered

Best Way to Refresh CSV Layers???

Question asked by chagan02 on Aug 4, 2014



I have been working on this for what seems like 6 months now.  I CANNOT get my CSV layers to refresh correctly.  I have built numerous functions with multiple combinations of code and the behavior is just not what I want, or does not work at all.


I have a series of functions that construct and add CSVLayers to the map.  Code is below for one.  The script runs all of them on load, then I use buttons to .show() or .hide() on command.  I need the layers to refresh themselves with new data from my web server every three minutes.  I have also tried using the refreshInterval property, without any luck.  Not only do I need the layers to refresh, I would like to have which ever layer is visible (if one of the CSV Layers is visible), remain visible.  If none are visible, then just refresh in the background. 


   var csv60min;
   var csv60mintextLayer;
   function csv60minfunc () {
   csv60min = new CSVLayer("symHydroViewer/data/60query.csv",{id:"csv60min"});
   csv60min.on("update-end", function(results){
   csv60mintextLayer = new GraphicsLayer({id:"csv60mintextLayer"});              
   arrayUtils.forEach(, function(feature, index){
   var lid =  feature.attributes.lid;
   var name =;
   var value = feature.attributes.value;
   var ffg = feature.attributes.ffg;
   var ratio = feature.attributes.ratio;
   var validtime = feature.attributes.obstime;
   var attr = {"Location ID":lid,"Location Name":name,"Obs Value":value,"FFG":ffg,"Ratio of FFG":ratio,"Obs Valid Time":validtime};                                                                         
   var geom = feature.geometry;
   var displayText = feature.attributes.value;
   var displayTextRatio = feature.attributes.ratio;
   coloralt = ratioColor(displayTextRatio);
   var font = new Font("12pt",Font.STYLE_NORMAL, Font.VARIANT_NORMAL,Font.WEIGHT_BOLD,"Helvetica");
   var textSymbol = new TextSymbol(displayText,font,new Color(coloralt));  
   csv60mintextLayer.add(new Graphic(geom, textSymbol, attr));});                  
   var infoTemplate = new InfoTemplate("Attributes", "${*}");  
   var blank = new Color([0, 0, 0, 0]); // hex is #ff4500
   var marker = new SimpleMarkerSymbol("solid", 0, null, blank);
   var renderer = new SimpleRenderer(marker);
   return [csv60min,csv60mintextLayer]