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

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

Description

(Added at v1.0)
Marker symbols are used to draw points and multipoints on the graphics layer.

MarkerSymbol has no constructor. Use SimpleMarkerSymbol or PictureMarkerSymbol.

Samples

Search for samples that use this class.

Class hierarchy

esri/symbols/Symbol
|_esri/symbols/MarkerSymbol

Subclasses

Properties

NameTypeSummary
angleNumberThe angle of the marker.
colorColorSymbol color.
sizeNumberSize of the marker in pixels.
typeStringThe type of symbol.
xoffsetNumberThe offset on the x-axis in pixels.
yoffsetNumberThe offset on the y-axis in pixels.

Methods

NameReturn typeSummary
setAngle(angle)MarkerSymbolRotates the symbol clockwise around its center by the specified angle.
setColor(color)SymbolSets the symbol color.
setOffset(x, y)MarkerSymbolSets the x and y offset of a marker in screen units.
setSize(size)MarkerSymbolSets the size of a marker in pixels.
toJson()ObjectConverts object to its ArcGIS Server JSON representation.
Property Details

<Number> angle

The angle of the marker.
Default value: 0

<Color> color

Symbol color.

<Number> size

Size of the marker in pixels.

<String> type

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

<Number> xoffset

The offset on the x-axis in pixels.
Default value: 0

<Number> yoffset

The offset on the y-axis in pixels.
Default value: 0
Method Details

setAngle(angle)

Rotates the symbol clockwise around its center by the specified angle.
Return type: MarkerSymbol
Parameters:
<Number> angle Required The angle value. 0 is pointing right and values progress clockwise.

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]));
  ...
});

setOffset(x, y)

Sets the x and y offset of a marker in screen units.
Return type: MarkerSymbol
Parameters:
<Number> x Required The X offset value in pixels.
<Number> y Required The Y offset value in pixels.

setSize(size)

Sets the size of a marker in pixels.
Return type: MarkerSymbol
Parameters:
<Number> size Required The width of the symbol in pixels.
Sample:
          var markerSymbol = new SimpleMarkerSymbol();
          markerSymbol.setPath(path);
       
          markerSymbol.setColor(new Color(color));
          markerSymbol.setOutline(null);
          markerSymbol.setSize("32");

toJson()

Converts object to its ArcGIS Server JSON representation.

Be aware that the angle in the JSON is different from MarkerSymbol.angle. The angle in the JSON follows the traditional ArcGIS specification and is rotated counter-clockwise, whereas the angle in the symbol is rotated clockwise. For example, if your MarkerSymbol has angle=30 (clockwise), this method will return a JSON object where angle=-30 (counter-clockwise):

{
  "color": [255,255,255,64],
  "size": 12,
  "angle": -30,
  "xoffset": 0,
  "yoffset": 0,
  "type": "esriSMS",
  "style": "esriSMSCross",
  "outline": {"color":[0,0,0,255],"width":1,"type":"esriSLS","style":"esriSLSSolid"}
}
Return type: Object
Show Modal