Hide Table of Contents
esri/dijit/util
esri/layer/pixelFilters
esri/process
esri/support
esri/workers
Class: SimpleLineSymbol

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

Description

(Added at v1.0)
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.

Explore the SimpleLineSymbol in the ArcGIS Symbol Playground. This is a place to explore and learn how to work with various properties and methods before implementing it into custom code. Try out new features, customize them, and copy the generated code into your own application. This sample provides a starting point so as to allow use of these features as quickly as possible.

Samples

Search for samples that use this class.

Class hierarchy

esri/symbols/Symbol
|_esri/symbols/LineSymbol
  |_esri/symbols/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.
markerObjectIndicates marker symbols present at the beginning and/or end of a SimpleLineSymbol.
styleStringThe line style.
typeStringThe type of symbol.
widthNumberWidth of line symbol in pixels.

Methods

NameReturn typeSummary
setColor(color)SymbolSets the symbol color.
setMarker(options)NoneSets marker symbols at the beginning and/or end of a SimpleLineSymbol.
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.
Parameters:
<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.
Parameters:
<Object> json Required JSON object representing the SimpleLineSymbol. View the Symbol Objects (Common data types in ArcGIS) 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.

<Object> marker

Indicates marker symbols present at the beginning and/or end of a SimpleLineSymbol. See the object specification table in the setMarker() method for details of the properties of this object. (Added at v3.23)

<String> style

The line style. See the Constants table for valid values.
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 type: Symbol
Parameters:
<Color> color Required Symbol color.
Sample:
require([
  "esri/Color", ... 
], function(Color, ... ) {
  symbol.setColor(new Color([255,255,0,0.5]));
  ...
});

setMarker(options)

Sets marker symbols at the beginning and/or end of a SimpleLineSymbol. (Added at v3.23)
Parameters:
<Object> options Required The options defining the marker style and placement. See the object specification table below.
Object Specifications:
<options>
<String> placement Required Indicates where the marker is placed on the line symbol. Valid values are begin, end, and begin-end.
<String> style Required Indicates the style of the marker to place on the line symbol. As of version 3.23, the only supported style is arrow.
Sample:

lineSymbol.setMarker({
  style: "arrow",
  placement: "end"
});

setStyle(style)

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

setWidth(width)

Sets the LineSymbol width.
Return type: LineSymbol
Parameters:
<Number> width Required Width of line symbol in pixels.
Sample:
require([
  "esri/symbols/SimpleLineSymbol", ... 
], function(SimpleLineSymbol, ... ) {
  var outline = new SimpleLineSymbol().setWidth(1);
  ...
});

toJson()

Converts object to its ArcGIS Server JSON representation.
Return type: Object
Show Modal