Feature Layer label not showing JS 3.x

01-06-2021 01:29 AM
Esri Contributor

Hi, I have a 2D widget and a piece of code to get label to show.

The layer loads fine however the label isn't. Can anyone advise?

_getLabelClass: function () {
      var labelSymbol = new TextSymbol();
      var defaultPlacement = "above-center"

      var json = {
        "labelExpressionInfo": { "expression": "$feature.symbolname" },
        "useCodedValues": false,
        "labelPlacement": defaultPlacement

      //create instance of LabelClass
      var lc = new LabelClass(json);
      lc.symbol = labelSymbol; // symbol also can be set in LabelClass' json
      return lc;

layer = new FeatureLayer(layerSettings.url, options);     
const layerInfoArr = [this._getLabelClass()];

2 Replies
Esri Regular Contributor

Can you share a simplified version of the app that reproduces this issue? If you inspect the layer after it gets added to the map, is the label info in there? Are there any warnings or errors in the console? Have you considered using the 4x version of the ArcGIS API for JavaScript?

0 Kudos
MVP Notable Contributor

If this is in any way helpful, I recently ran into a similar issue.


Features don't render in any 3x maps, but appear in 4x maps. If it's relevant, the features were submitted via a Notebook using the Spatially Enabled DataFrame.

- Josh Carlson
Kendall County GIS
0 Kudos