AnsweredAssumed Answered

How to label feature layer

Question asked by smiller25 on Jul 3, 2018
Latest reply on Jul 5, 2018 by rscheitlin

In my app, I construct a FeatureLayer with data from a query, and I want to add a label to the polylines that display the data value. I've tried a couple things, including the code below, but nothing has worked. 

 

layer.hasLabels = true;
var labelSymbol = new esri.symbol.TextSymbol('');

var json = {
   "labelExpressionInfo": {"value": "{thecolor}"},
   "useCodedValues": false,
   "labelPlacement":"above-start",
   "fieldInfos": [{fieldName: "thecolor"}]
};
this.map.showLabels = true;
//create instance of LabelClass
var lc = new LabelClass(json);
lc.symbol = labelSymbol; // symbol also can be set in LabelClass' json
layer.setLabelingInfo([ lc ]);

Attachments

Outcomes