Colors in arcgis javascript api

2862
8
05-15-2016 11:59 PM
bharathreddy
Occasional Contributor

Can anyone provide different graphic colors for simple line symbol and symbol fill symbol

0 Kudos
8 Replies
PanagiotisPapadopoulos
Esri Regular Contributor

on simple line symbol and simple fill symbol you can change the color by setting the Color parameter

require([
 
"esri/symbols/SimpleLineSymbol", "esri/Color", ...
], function(SimpleLineSymbol, Color, ... ) {
 
var sls = new SimpleLineSymbol(
   
SimpleLineSymbol.STYLE_DASH,
   
new Color([255,0,0]),
   
3
 
);
 
...
});

see the javascript help

SimpleLineSymbol | API Reference | ArcGIS API for JavaScript

PanagiotisPapadopoulos
Esri Regular Contributor

Also the same for fill symbol

require([
 
"esri/symbols/SimpleFillSymbol", "esri/symbols/SimpleLineSymbol", "esri/Color", ...
], function(SimpleFillSymbol, SimpleLineSymbol, Color, ... ) {
 
var sfs = new SimpleFillSymbol(SimpleFillSymbol.STYLE_SOLID,
   
new SimpleLineSymbol(SimpleLineSymbol.STYLE_DASHDOT,
   
new Color([255,0,0]), 2),new Color([255,255,0,0.25])
 
);
 
...
});

JerryGarcia
Occasional Contributor II

The fill is always black for me.  The color property does not appear to change the color, i.e. STYLE_VERTICAL.  Always black.

Is this a known issue?  Thanks!

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Jerry,

   This has been a long standing bug/limitation and can been seen and tested in the Symbol playground 

bharathreddy
Occasional Contributor

Hello Robert,

The link wich you gave was excellent. 

Thank u very much

0 Kudos
MiriamBrockmann
Occasional Contributor

Interestingly, the colors you set for the diagonal or all other Fillings are displayed correctly when you print

the graphic. This is how we handle it. You can set the color, but only in the printout it will be visible.

JohnGrayson
Esri Regular Contributor

It's been some time since I tried this, but I believe another option if your data is being accessed via an ArcGIS Server Map Service (10.1+) is to switch to an ArcGISDynamicMapServiceLayer and use the LayerDrawingOptions so the symbol is rendered on the server.

0 Kudos
MiriamBrockmann
Occasional Contributor

Hey John!

But the main Problem stays when you want to draw your own Graphic.

In this Point the Api says that the color only applies, when you have a solid filling.

The other Fillings ignore the colorsetting on screen like in the "Playground"-Example above.

0 Kudos