custom render after a Geoprocess

464
0
10-02-2013 12:22 PM
ChrisSeeger
New Contributor II
I have tried to use the class break renderer with the result of a geoprocess but have had not luck so instead I wrote my own.
It renders the resulting counties according to the percent. However if I pan/zoom the map the colors revert to a default.
Any ideas on why this would happen?  Also if anyone has a simple example of a class render working on the resulting features of a geoprocess I would like to see it.


Here is the function that receives the output and draws it to screen. This works fine until I pan or zoom  - then the polygons loose their symbology.



function drawMap(results, messages) {
console.log("geocodeCountGP is running");
var polySymbol = new esri.symbol.SimpleFillSymbol();
polySymbol.setOutline(new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_SOLID, new dojo.Color([0,0,0,1]), 1));

polySymbol.setColor(new dojo.Color([56, 150, 0,0.9]));

var features = results[0].value.features;

var infoTemplate = new esri.InfoTemplate("${COUNTY}","Count: ${Join_Count}");

for (var f=0, fl=features.length; f<fl; f++) {
  var feature = features;
  percent = features.attributes.Percent;
 
  if (percent < 5) {polySymbol.setColor(new dojo.Color([255,255,51,.5]))};
  if (percent >= 5 && percent < 10) {polySymbol.setColor(new dojo.Color([56, 168, 0,0.25]))};
  if (percent >= 10 && percent < 20) {polySymbol.setColor(new dojo.Color([56, 168, 0,0.5]))};
  if (percent >= 20) {polySymbol.setColor(new dojo.Color([56, 168, 0,0.75]))}
 
  feature.setSymbol(polySymbol);
  map.graphics.add(feature);
  map.graphics.add(feature.setInfoTemplate(infoTemplate));
}
0 Kudos
0 Replies