Add Feature Layer created from JSON to Legend

860
4
11-17-2016 11:17 AM
ArjunDongre
Occasional Contributor

I have created a geoprocessing task that performs a join, and converts to a JSON which then can be retrieved by the client. The reason for this is to limit the amount of memory being used on the server. I do not want to create lots of feature classes on the server, I want the layers to be stored client side. I also strip some fields from features in my JSON before turning it into a feature collection for use in a Feature Layer. I use a Class Breaks Renderer to visualize my data on the map. I am now trying to display the feature layer in a legend, but am having trouble doing so. Is it possible to display my info in the legend? Thanks.

0 Kudos
4 Replies
RobertScheitlin__GISP
MVP Emeritus

Arjun,

   Sure The biggest part of making that happen is to be sure to define the drawingInfo of the layer in the layerDefinition when you create the FeatureLayer.

0 Kudos
ArjunDongre
Occasional Contributor

This information is not provided in the JSON. Shouldn’t that already be created when the classrenderer is created?

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Arjun,

  No if you are creating the FeatureLayer from a FeatureCollection you are responsible for providing all that info in the LayerDefinition.

0 Kudos
ArjunDongre
Occasional Contributor

I really feel like it should be a lot easier…thinking about just using a dgrid and populating as I already have my color codes and breaks.

0 Kudos