Hide Table of Contents
esri
Map
plugins
process
toolbars
workers
Class: SimpleLineSymbol
[ AMD Module Require | Legacy Module Require ]

require(["esri/symbols/SimpleLineSymbol"], function(SimpleLineSymbol) { /* code goes here */ });

Description

Line symbols are used to draw linear features on the graphics layer. SimpleLineSymbol is either a solid line or a predefined pattern of dashes and dots.

Samples

Search for samples that use this class.

Class hierarchy

esri/symbol/Symbol
|_esri/symbol/LineSymbol
  |_esri/symbol/SimpleLineSymbol

Subclasses

Constructors

NameSummary
new SimpleLineSymbol()Creates a new empty SimpleLineSymbol object
new SimpleLineSymbol(style,color,width)Creates a new SimpleLineSymbol object with parameters
new SimpleLineSymbol(json)Creates a new SimpleLineSymbol object using a JSON object

Constants

NameDescription
STYLE_DASHThe line is made of dashes.
STYLE_DASHDOTThe line is made of a dash-dot pattern.
STYLE_DASHDOTDOTThe line is made of a dash-dot-dot pattern.
STYLE_DOTThe line is made of dots.
STYLE_LONGDASHLine is constructed of a series of dashes.
STYLE_LONGDASHDOTLine is constructed of a series of short dashes.
STYLE_NULLThe line has no symbol.
STYLE_SHORTDASHLine is constructed of a series of short dashes.
STYLE_SHORTDASHDOTLine is constructed of a dash followed by a dot.
STYLE_SHORTDASHDOTDOTLine is constructed of a series of a dash and two dots.
STYLE_SHORTDOTLine is constructed of a series of short dots.
STYLE_SOLIDThe line is solid.

Properties

NameTypeSummary
colorColorSymbol color
styleStringThe line style.
typeStringThe type of symbol
widthNumberWidth of line symbol in pixels

Methods

NameTypeSummary
setColor(color)SymbolSets the symbol color
setStyle(style)SimpleLineSymbolSets the line symbol style
setWidth(width)LineSymbolSets the LineSymbol width
toJson()ObjectConverts object to its ArcGIS Server JSON representation
Constructor Details

new SimpleLineSymbol()

Creates a new empty SimpleLineSymbol object.
Sample:
require([
  "esri/symbols/SimpleLineSymbol", ... 
], function(SimpleLineSymbol, ... ) {
  var sls = new SimpleLineSymbol();
  ...
});

new SimpleLineSymbol(style,color,width)

Creates a new SimpleLineSymbol object with parameters.
Arguments:
<String> style Required See Constants table for values.
<Color> color Required Symbol color.
<Number> width Required Width of the line in pixels.
Sample:
require([
  "esri/symbols/SimpleLineSymbol", "esri/Color", ... 
], function(SimpleLineSymbol, Color, ... ) {
  var sls = new SimpleLineSymbol(SimpleLineSymbol.STYLE_DASH,
    new Color([255,0,0]), 3)
  );
  ...
});

new SimpleLineSymbol(json)

Creates a new SimpleLineSymbol object using a JSON object.
Arguments:
<Object> json Required

JSON object representing the SimpleLineSymbol. View the REST API Reference for Symbol Objects for details on creating a JSON symbol. Note that when specifying symbol width and height using JSON the values should be entered in points, the JavaScript API then converts the point values to pixels.

Property Details

<Color> color

Symbol color.

<String> style

The line style. See the Constants table for valid values. The default value is STYLE_SOLID.
Default value: STYLE_SOLID

<String> type

The type of symbol.
Known values: simplemarkersymbol | picturemarkersymbol | simplelinesymbol | cartographiclinesymbol | simplefillsymbol | picturefillsymbol | textsymbol

<Number> width

Width of line symbol in pixels.
Default value: 1
Method Details

setColor(color)

Sets the symbol color.
Return value: Symbol
Arguments:
<Color> color Required Symbol color.
Sample:

symbol.setColor(new esri.Color([255,255,0,0.5]));

setStyle(style)

Sets the line symbol style.
Return value: SimpleLineSymbol
Arguments:
<String> style Required Line style. See the Constants table for valid values.

setWidth(width)

Sets the LineSymbol width.
Return value: LineSymbol
Arguments:
<Number> width Required Width of line symbol in pixels.
Sample:

var outline = new esri.symbol.SimpleLineSymbol().setWidth(1);

toJson()

Converts object to its ArcGIS Server JSON representation.
Return value: Object