Add labels to a FeatureLayer
Explore in the sandboxView live
This sample demonstrates how to add labels to a FeatureLayer in a MapView. You can display labels either by setting the labelInfo property of the FeatureLayer, or by loading a PortalItem with labels already defined.
The value of the MARKER_ACTIVITY
field of the FeatureLayer is used to label each feature in the view, which shows Forest Service Recreation Opportunities in the United States.
To add labels to the layer, first we create a LabelClass and assign values for various properties, such as color and font. See the Labeling guide page for more information and known limitations.
This sample loads a PortalItem from ArcGIS Online, then adds the label class to the labelingInfo
property, and applies a renderer.