Hide Table of Contents
esri
esri/arcgis
esri/dijit
esri/dijit/analysis
esri/dijit/geoenrichment
esri/dijit/geoenrichment/ReportPlayer
esri/geometry
esri/layers
esri/renderers
esri/symbols
esri/tasks
esri/tasks/datareviewer
esri/tasks/geoenrichment
esri/tasks/locationproviders
dojo.require("esri.symbols.jsonUtils")
esri.symbol.fromJson().| Name | Return type | Summary |
|---|---|---|
| fromJson(json) | Symbol | Converts input json into a symbol, returns null if the input json represents an unknown or unsupported symbol type. |
| getShapeDescriptors(symbol) | Object | Returns the shape description properties for the given symbol as defined by the Dojo GFX API. |
var duplicate = esri.symbol.fromJson(simpleMarkerSymbol.toJson());
var symbol = jsonUtils.fromJson({
"angle": -30,
"xoffset": 0,
"yoffset": 0,
"type": "esriPMS",
"url": "http://www.esri.com/careers/profiles/~/media/Images/Content/graphics/icons/socialmedia/pinterest1.png",
"width": 18,
"height": 18
});Symbol<> json |
Required | The input JSON. |
| <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. |
Object<> symbol |
Required | The input symbol. |
[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>