renderer for graphicslayer not working?

1984
2
Jump to solution
02-07-2014 08:09 AM
EvanBossett
New Contributor
I am trying to add a renderer to a graphicslayer.  My graphics layer shows up fine and i can control the symbology manually (If i change the symbol color, it changes,etc.) 

However, if i create a renderer and add it to the layer, the "default" symbology is still retained.

Please help.

Thank you.


//CODE
symbol1 = new esri.symbol.SimpleFillSymbol().setColor(new dojo.Color([255, 0, 0,0.5]))
gl = new esri.layers.GraphicsLayer();
                                  
var attr = {"MY_VALUE":5}
gl.add(
         new esri.Graphic(
         new esri.geometry.Point(-75.03810508573053, 40.26871269474917),
         symbolX,
         attr
   )
)

map.addLayer(gl);

renderer1 = new esri.renderer.ClassBreaksRenderer(symbol1, "MY_VALUE");
renderer1.addBreak(0,3,new esri.symbol.SimpleFillSymbol().setColor(new dojo.Color([255, 0, 0,0.5])));
renderer1.addBreak(4,7,new esri.symbol.SimpleFillSymbol().setColor(new dojo.Color([0, 255, 0,0.5])));
renderer1.addBreak(8,Infinity,new esri.symbol.SimpleFillSymbol().setColor(new dojo.Color([0,0,255,0.5])));

gl.setRenderer(renderer1)
0 Kudos
1 Solution

Accepted Solutions
TyroneLigon
Occasional Contributor
If I'm reading this correctly, you want to use the renderer symbology but the symbol you're adding to the graphic is what's being drawn. If that's the case, try using 'null' as your symbol value in the graphic constructor.

View solution in original post

0 Kudos
2 Replies
TyroneLigon
Occasional Contributor
If I'm reading this correctly, you want to use the renderer symbology but the symbol you're adding to the graphic is what's being drawn. If that's the case, try using 'null' as your symbol value in the graphic constructor.
0 Kudos
EvanBossett
New Contributor
I appreciate the prompt response.
You understand my problem correctly.

however, it is worse

graphics drawn using the following show up (but do not have a renderer) :

map.graphics.add(g);

however, my graphicslayer is not showing up (even when I remove the renderer). 
I did include code:

gl.visible=true;

any help would be appreciated.

thank you.
0 Kudos