AnsweredAssumed Answered

Feature Labeling Issue

Question asked by lloydbronn on Apr 20, 2017
Latest reply on Apr 24, 2017 by lloydbronn

I'm following this example to label a feature layer. I keep getting this error in the console: TypeError: Cannot read property 'setSize' of undefined. I can't figure out what the issue might be. Here is my code snippet. 

 

 

var waterbasinsUrl = "http://<ourserver>/arcgis/rest/services/Waterbasins/MapServer/0";
        var waterbasins = new FeatureLayer(waterbasinsUrl, {
          id: "waterbasins",
          outFields: ["Name"]
        });
          
          var labelColor = new Color("#666");

          
          var basinLabel = new TextSymbol().setColor(labelColor);
        basinLabel.font.setSize("14pt");
        basinLabel.font.setFamily("arial");

       
        var json = {
          "labelExpressionInfo": {"value": "{Name}"}
        };
       
        var labelClass = new LabelClass(json);
        labelClass.symbol = basinLabel;
        waterbasins.setLabelingInfo([ labelClass ]);
          
          map.addLayer(waterbasins);

Outcomes