AnsweredAssumed Answered

Renderers fromJson Method

Question asked by jestanford on Aug 3, 2017
Latest reply on Aug 3, 2017 by jestanford

Hi!

Does anybody have a working example of how to use the fromjson method on the esri/renderers/jsonUtils module?

 

Using the following code I expect a blue symbology to be applied but the blueRenderer object always ends up 'undefined'.

 

var featureLayer = new FeatureLayer("https://services.arcgis.com/P3ePLMYs2RVChkJx/arcgis/rest/services/USA_Counties/FeatureServer/0");
var rendererConfig = '{"color"[0,112,255,64],"outline": {"color": [0,0,0,255],"width": 1,"type": "esriSLS","style": "esriSLSSolid","marker": null},"type": "esriSFS","style": "esriSFSSolid"}';
var blueRenderer = jsonUtils.fromJson(rendererConfig);
featureLayer.setRenderer(blueRenderer);
map.addLayer(featureLayer);

 

 

Full code here - https://codepen.io/js_gsi/pen/prNvXJ.

 

Maybe my JSON is not well formed? I pulled it from this playground.

 

Thank you!

Jill

Outcomes