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);
Solved! Go to Solution.
You sure you don't have some of your requires out of order then?
Lloyd,
This a code snippet for set the TextSymbols font size:
require([
"esri/symbols/TextSymbol", "esri/symbols/Font", ...
], function(TextSymbol, Font, ... ) {
var textSymbol = new TextSymbol( ... );
var font = new Font();
font.setSize("12pt");
font.setWeight(Font.WEIGHT_BOLD);
textSymbol.setFont(font);
...
});
Now I get this: TypeError: textSymbol.setFont is not a function
You sure you don't have some of your requires out of order then?
That was it. My SimpleLineSymbol was out of order