Labeling

Labels help identify features, establish a visual hierarchy of important features, and focus the user's attention on the map's purpose. Label options and capabilities (such as label placement and available fonts) vary depending on the layer type, geometry type, and view type (2D or 3D).

This guide page will demonstrate the possible labeling scenarios based on those different properties and fonts. The FAQ at the bottom contains information about useful workflows and answers to common questions. Additionally, this guide page will explore labeling adjacent use cases, such as text in TextSymbol and TextSymbol3DLayer, for text symbol previews using symbolUtils.renderPreviewHTML, and print considerations.

2D MapView labeling

Labeling is supported for FeatureLayer, CSVLayer, GeoJSONLayer, StreamLayer, OGCFeatureLayer, and WFSLayer in 2D MapViews. The labelingInfo property is specified as an array of LabelClass objects, which contains labelExpressionInfo, labelPlacement, and TextSymbol. The TextSymbol class supports altering the label graphic's color, font, halo, and other properties. Labeling is supported for Points, Polylines, and Polygons.

Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
const labelClass = {  // autocasts as new LabelClass()
  symbol: {
    type: "text",  // autocasts as new TextSymbol()
    color: "white",
    haloColor: "blue",
    haloSize: 1,
    font: {  // autocast as new Font()
       family: "Noto Sans",
       size: 14
     }
  },
  labelPlacement: "above-right",
  labelExpressionInfo: {
    expression: "$feature.Team + TextFormatting.NewLine + $feature.Division"
  },
  maxScale: 0,
  minScale: 25000000,
  where: "Conference = 'AFC'"
};

const labelLayer = new FeatureLayer({
  portalItem: {  // autocasts as new PortalItem()
    id: "7f0bfc7bf67a407d8efebf584f6d956d"
  },
  labelingInfo: [labelClass]
});

Sample: Multi-line labels

3D SceneView labeling

Labeling is supported for all layer types with a labelingInfo property, such as FeatureLayer and SceneLayer. This property is specified as an array of LabelClass objects, which contains the labelExpressionInfo, labelPlacement, and TextSymbol3DLayer. The TextSymbol3DLayer class supports altering the label graphic's material, font, halo, and other properties.

Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
const labelClass = {  // autocasts as new LabelClass()
  symbol: {
    type: "label-3d", // autocasts as new LabelSymbol3D()
    symbolLayers: [
      {
        type: "text", // autocasts as new TextSymbol3DLayer()
        material: {
          color: "purple"
        },
        font: {  // autocasts as new Font()
          family: "Just Another Hand",
          weight: bold
        },
        size: 22
      }
    ]
  },
  labelPlacement: "below-center",
  labelExpressionInfo: {
    expression: 'DefaultValue($feature.CITY_NAME, "no data")'
  }
};

const labelLayer = new FeatureLayer({
  url: "https://services.arcgis.com/V6ZHFr6zdgNZuVG0/arcgis/rest/services/CITIES_EastUSA/FeatureServer/0",
  labelingInfo: [labelClass]
});

Known Limitations (SceneView)

Sample: Flat vs. volumetric 3D symbol layers

Fonts

Typically, you won't need to be concerned with where the font files are hosted or which file types are used. However, if you are working with custom fonts or in a disconnected environment, it is worth reading this entire section. There are different types of font files used for labeling that are accessible from different locations, depending on the class, layer type, and if you are working in 2D or 3D. There are multiple ways that fonts can be consumed:

  • From https://static.arcgis.com/fonts in pbf format
  • From https://static.arcgis.com/fonts/woff2 in woff2 format
  • Referenced from a server in pbf, otf, ttf, woff, or woff2 format
  • From the fonts available on the user's computer and web browser

MapImageLayer fonts

MapImageLayer fonts come from a web browser or the user's computer.

Labeling is supported for MapImageLayer by setting the labelingInfo property on the Sublayer class. The labelingInfo property is specified as an array of LabelClass objects, containing the labelExpression, labelPlacement, and TextSymbol. The TextSymbol class supports altering the label graphic's color, font, halo, and other properties. Labeling is supported for Points, Polylines, and Polygons.

The supported font families for MapImageLayers in a MapView depend on the fonts installed on the ArcGIS Server that published the layer. This is the same for 2D MapViews and 3D SceneViews. To check what fonts are available on ArcGIS Server, run the Available Fonts task under Home > services > System > PublishingTools (GPServer) (requires admin access). To add a new font, the font must be installed on your computer and accessible to ArcGIS Server by registering it using ArcGIS Desktop. If an app uses a font that is not installed, the Font class implements a fallback mechanism that will use the default font family value, which is sans-serif.

Sample: MapImageLayer - label sublayer features

Non-MapImageLayer fonts

Support for Font.family, Font.style, and Font.weight properties are based on the fonts files. We host many fonts on https://static.arcgis.com/fonts that can be easily accessed for labeling.

If a Font is unavailable, it will use the default font family, sans-serif. This uses the Arial Unicode MS font file. Fonts with bold and/or italic require these properties to be set in the Font.style and Font.weight properties, as opposed to being set in the Font.family. To see which fonts support what types of characters (e.g. Latin, Cyrillic, CJKV), you can search for the font name in the Microsoft Typography or Google Fonts.

Non-MapImageLayer layers that can be labeled:
CSVLayer, FeatureLayer, GeoJSONLayer, OGCFeatureLayer, StreamLayer, WFSLayer.

List of fonts currently hosted on https://static.arcgis.com/fonts in pbf and woff2 formats (currently Palatino Linotype Regular, Arial Regular, Arial Bold, Arial Bold Italic, and Arial Italic are only available in pbf):

FontPreviewCode
Abril Fatface RegularAbril Fatface RegularCopy
Alegreya BoldAlegreya BoldCopy
Alegreya Bold ItalicAlegreya Bold ItalicCopy
Alegreya ItalicAlegreya ItalicCopy
Alegreya RegularAlegreya RegularCopy
Alegreya SC BoldAlegreya SC BoldCopy
Alegreya SC ItalicAlegreya SC ItalicCopy
Alegreya SC RegularAlegreya SC RegularCopy
Alegreya Sans ItalicAlegreya Sans ItalicCopy
Amarante RegularAmarante RegularCopy
Amatic SC BoldAmatic SC BoldCopy
Arial BoldArial BoldCopy
Arial Bold ItalicArial Bold ItalicCopy
Arial ItalicArial ItalicCopy
Arial RegularArial RegularCopy
Arial Unicode MS BoldArial Unicode MS BoldCopy
Arial Unicode MS RegularArial Unicode MS RegularCopy
Atomic Age RegularAtomic Age RegularCopy
Audiowide RegularAudiowide RegularCopy
Avenir Next LT Pro BoldAvenir Next LT Pro BoldCopy
Avenir Next LT Pro Bold ItalicAvenir Next LT Pro Bold ItalicCopy
Avenir Next LT Pro Demi ItalicAvenir Next LT Pro Demi ItalicCopy
Avenir Next LT Pro ItalicAvenir Next LT Pro ItalicCopy
Avenir Next LT Pro LightAvenir Next LT Pro LightCopy
Avenir Next LT Pro Light ItalicAvenir Next LT Pro Light ItalicCopy
Avenir Next LT Pro Medium BoldAvenir Next LT Pro Medium BoldCopy
Avenir Next LT Pro Medium Bold ItalicAvenir Next LT Pro Medium Bold ItalicCopy
Avenir Next LT Pro RegularAvenir Next LT Pro RegularCopy
Avenir Next LT Pro Regular BoldAvenir Next LT Pro Regular BoldCopy
BellTopo Sans BoldBellTopo Sans BoldCopy
BellTopo Sans Bold ItalicBellTopo Sans Bold ItalicCopy
BellTopo Sans ItalicBellTopo Sans ItalicCopy
BellTopo Sans RegularBellTopo Sans RegularCopy
Belleza RegularBelleza RegularCopy
Black Ops One RegularBlack Ops One RegularCopy
Cabin Sketch BoldCabin Sketch BoldCopy
Cabin Sketch RegularCabin Sketch RegularCopy
Coming Soon RegularComing Soon RegularCopy
FGDC GeoAge RegularFGDC GeoAge RegularCopy
Homemade Apple RegularHomemade Apple RegularCopy
IM FELL DW Pica PRO ItalicIM FELL DW Pica PRO ItalicCopy
IM FELL DW Pica PRO RegularIM FELL DW Pica PRO RegularCopy
Josefin Sans RegularJosefin Sans RegularCopy
Josefin Sans Semibold ItalicJosefin Sans Semibold ItalicCopy
Josefin Slab BoldJosefin Slab BoldCopy
Josefin Slab Bold ItalicJosefin Slab Bold ItalicCopy
Josefin Slab ItalicJosefin Slab ItalicCopy
Josefin Slab Light ItalicJosefin Slab Light ItalicCopy
Josefin Slab RegularJosefin Slab RegularCopy
Josefin Slab Thin ItalicJosefin Slab Thin ItalicCopy
Just Another Hand RegularJust Another Hand RegularCopy
Kranky RegularKranky RegularCopy
Life Savers BoldLife Savers BoldCopy
Loved by the King RegularLoved by the King RegularCopy
Merriweather BoldMerriweather BoldCopy
Merriweather Bold ItalicMerriweather Bold ItalicCopy
Merriweather ItalicMerriweather ItalicCopy
Merriweather RegularMerriweather RegularCopy
Montserrat BoldMontserrat BoldCopy
Montserrat ItalicMontserrat ItalicCopy
Montserrat Medium ItalicMontserrat Medium ItalicCopy
Montserrat RegularMontserrat RegularCopy
Montserrat Semibold ItalicMontserrat Semibold ItalicCopy
Noto Sans BoldNoto Sans BoldCopy
Noto Sans Bold ItalicNoto Sans Bold ItalicCopy
Noto Sans ItalicNoto Sans ItalicCopy
Noto Sans RegularNoto Sans RegularCopy
Noto Serif BoldNoto Serif BoldCopy
Noto Serif Bold ItalicNoto Serif Bold ItalicCopy
Noto Serif ItalicNoto Serif ItalicCopy
Noto Serif RegularNoto Serif RegularCopy
Old Standard TT BoldOld Standard TT BoldCopy
Old Standard TT ItalicOld Standard TT ItalicCopy
Old Standard TT RegularOld Standard TT RegularCopy
Orbitron BoldOrbitron BoldCopy
Orbitron RegularOrbitron RegularCopy
Oregano ItalicOregano ItalicCopy
Oregano RegularOregano RegularCopy
Oswald BoldOswald BoldCopy
Oswald RegularOswald RegularCopy
Pacifico RegularPacifico RegularCopy
Palatino Linotype RegularPalatino Linotype RegularCopy
Playfair Display BlackPlayfair Display BlackCopy
Playfair Display BoldPlayfair Display BoldCopy
Playfair Display Bold ItalicPlayfair Display Bold ItalicCopy
Playfair Display ItalicPlayfair Display ItalicCopy
Playfair Display RegularPlayfair Display RegularCopy
Playfair Display SC BoldPlayfair Display SC BoldCopy
Playfair Display SC RegularPlayfair Display SC RegularCopy
Redressed RegularRedressed RegularCopy
Risque RegularRisque RegularCopy
Roboto BoldRoboto BoldCopy
Roboto Bold ItalicRoboto Bold ItalicCopy
Roboto Condensed ItalicRoboto Condensed ItalicCopy
Roboto Condensed Light ItalicRoboto Condensed Light ItalicCopy
Roboto ItalicRoboto ItalicCopy
Roboto RegularRoboto RegularCopy
Rye RegularRye RegularCopy
Special Elite RegularSpecial Elite RegularCopy
Syncopate BoldSyncopate BoldCopy
Syncopate RegularSyncopate RegularCopy
Tangerine RegularTangerine RegularCopy
Ubuntu BoldUbuntu BoldCopy
Ubuntu Bold ItalicUbuntu Bold ItalicCopy
Ubuntu Condensed RegularUbuntu Condensed RegularCopy
Ubuntu Italic