jsonUtils
require(["esri/symbols/support/jsonUtils"], function(symbolJsonUtils) { /* code goes here */ });
esri/symbols/support/jsonUtils
Provides a utility method used to deserialize a JSON symbol object returned by the REST API.
Method Overview
Name | Return Type | Summary | Object | |
---|---|---|---|---|
Symbol | Creates a new instance of an appropriate Symbol class and initializes it with values from a JSON object generated from a product in the ArcGIS platform. more details | more details | jsonUtils |
Method Details
- fromJSON(json){Symbol}
Creates a new instance of an appropriate Symbol class and initializes it with values from a JSON object generated from a product in the ArcGIS platform. The object passed into the input
json
parameter often comes from a response to a query operation in the REST API or a toJSON() method from another ArcGIS product. See the Using fromJSON() topic in the Guide for details and examples of when and how to use this function.When you create a MarkerSymbol, SimpleMarkerSymbol or PictureMarkerSymbol from a JSON object, you may specify a property angle to rotate the symbol. 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.
Parameter:json ObjectA JSON representation of the instance in the ArcGIS format. See the ArcGIS REST API documentation for examples of the structure of various input JSON objects.
Returns:Type Description Symbol Returns a new instance of an appropriate Symbol class. Example:// The angle=-30 in the JSON will create a symbol rotated -30 degrees counter-clockwise; that is, // 30 degrees clockwise, which symbol.angle=30 would also produce. 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 });