Feature Layer label not showing JS 3.x

339
2
01-06-2021 01:29 AM
VictorTey
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()];
layer.setLabelingInfo(layerInfoArr);

this.map.addLayer(layer);
2 Replies
Noah-Sager
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
jcarlson
MVP Notable Contributor

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

https://maps.co.kendall.il.us/portal/home/item.html?id=5cdf287c15cb49c3b18d8f3811634781

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