Hey everybody,
Is there a way to change the transparency of a particular graphic or is this only possible for a graphic layer?
Tim
Solved! Go to Solution.
Hi Tim,
If the graphics is already created, you can use the setSymbol method to do this. Ex:
var symbol = new SimpleFillSymbol(SimpleFillSymbol.STYLE_SOLID,
new SimpleLineSymbol(SimpleLineSymbol.STYLE_SOLID,
new Color([255,0,0]), 2),new Color([255,255,0,0.25])
)
map.graphics.graphics[2].setSymbol(symbol);
Hi Tim,
If the graphics is already created, you can use the setSymbol method to do this. Ex:
var symbol = new SimpleFillSymbol(SimpleFillSymbol.STYLE_SOLID,
new SimpleLineSymbol(SimpleLineSymbol.STYLE_SOLID,
new Color([255,0,0]), 2),new Color([255,255,0,0.25])
)
map.graphics.graphics[2].setSymbol(symbol);
Thanks Jake!
One more question, how does this work if my color is in Hex string?
According to the documentation, the transparency option is only available for RGB colors
Thanks Ken, I guess I need to change my color palette then to return RGB values.
You can change the transparency of the color you assign different graphics.
var trans = Math.random();
// lineSymbol used for freehand polyline, polyline and line.
var lineSymbol = new CartographicLineSymbol(
CartographicLineSymbol.STYLE_SOLID,
new Color([255, 0, 0, trans]), 10,
CartographicLineSymbol.CAP_ROUND,
CartographicLineSymbol.JOIN_MITER, 5
);