Namespace: symbol

Description

The esri.symbol namespace contains utility methods that are not associated with any class.

Samples

Search for samples that use this class.  

Methods

Method Return Value Description
esri.symbol.fromJson() Symbol Converts input json into a symbol, returns null if the input json represents an unknown or unsupported symbol type.
esri.symbol.getShapeDescriptors() Object Returns the shape description properties for the given symbol as defined by the Dojo GFX API. Using this method, you can apply ArcGIS symbology to shapes or graphics not created within a GraphicsLayer.
Methods Detail

esri.symbol.fromJson()

Converts input json into a symbol, returns null if the input json represents an unknown or unsupported symbol type. The input json argument typically comes from one of the following:
  1. Calling the symbol.toJson() method
    var duplicate = esri.symbol.fromjson(simpleMarkerSymbol.toJson());
  2. Symbol object returned from REST.
Return value: Symbol

esri.symbol.getShapeDescriptors()

Returns the shape description properties for the given symbol as defined by the Dojo GFX API. Using this method, you can apply ArcGIS symbology to shapes or graphics not created within a GraphicsLayer.

Properties of the returned object include:

<Object> fill Defines how to fill a shape. The properties of this object are described in the dojo documentation.
<Object> stroke An object that defines how to draw the outline of a shape. The properties of this object are described in the dojo documentation.
<Object> defaultShape An object that defines a default geometry for the given symbol. It will always have a property named "type" that uniquely identifies the shape. The type property can have one of the following values based on the symbol: circle, path, or image. It is important to note that the geometry defined by this object will always be centered at the top-left corner (x = 0, y = 0) of the surface it is attached to.

You can quickly create a GFX shape with ArcGIS symbology with the help of these descriptors using the createShape method of the surface. Alternatively, you can choose to change the shape description before creating the shape. (As of v2.0)
Return value: Object
Code snippets:

[JavaScript]
  var mySurface = dojox.gfx.createSurface(dojo.byId("surface"), 50, 50);
  var descriptors = esri.symbol.getShapeDescriptors(symbol);
  var shape = mySurface.createShape(descriptors.defaultShape)
                .setFill(descriptors.fill)
                .setStroke(descriptors.stroke);
  shape.applyTransform({ dx: 25, dy: 25 }); // center the shape at coordinates (25, 25)
 
[HTML]
  <div id="surface"></div>