Multi-line labels

13330
11
12-12-2017 01:11 PM
deleted-user-P-Gckloxqib2
New Contributor III

Does anyone know how to label a feature class with multiple lines in ArcGIS Online? On Desktop, labels can be done via:

Zip Code

City Name 

Population 

... I am hoping to do the same with ArcGIS Online. 

Thanks for your help!  

Tags (2)
0 Kudos
11 Replies
MicahBabinski
Occasional Contributor III

Hi Sunnie,

If you are using a feature layer, you can do it this way:

  1. Expand the layer in the table of contents and click on the three dots: 
  2. In the menu, click Create Labels - if you don't see this it's probably because you are working with a map image layer or some other type of layer that does not allow you to create labels based on the feature data
  3. In the text drop-down, choose New Expression (at the bottom of the list)
  4. In the expression window, mix and match fields and String elements to create your perfect multi-field label expression:

Note that these expressions are built using ArcGIS Arcade. Plenty of help docs exist to help you become an expert!

Good luck,

Micah

KenBuja
MVP Esteemed Contributor

Unfortunately, since Arcade doesn't support NewLine in the map viewer or template apps, you can't put them on separate lines. However, there does appear to be a workaround as noted in this thread.

Arcade Text Constant for TextFormatting.NewLine is adding space instead of new line 

XanderBakker
Esri Esteemed Contributor

The workaround that was mentioned does not apply for labels. There is some advancement since the playground will now show the multi line result, however this will not be applied for the labels in the map: 

What you can do is duplicate the layer and and use the label positioning to have two lines (with 3 lines it will not fit and it will not show one of the labels).

So copy the layer and use different alignments for the labels of each layer:

 and 

to go from this

to this

SarahAnderson1
New Contributor II

Looks like there is only the option to determine label placement for points and lines, not for polygons. Any suggested workarounds for polygons?

Thanks,

Sarah

0 Kudos
XanderBakker
Esri Esteemed Contributor

You could create label point for the polygons and label those, but that would be a complex way to achieve something that should be so easy.

0 Kudos
KamillePreto
Occasional Contributor II

Any ideas as to how to get this Expression to result in a double line label?

I copied exactly what was above in xander_bakker‌'s comment and am not having the same results, as you can see in the "Results" tab, it's only staying a single line.

0 Kudos
XanderBakker
Esri Esteemed Contributor

At this moment it is not possible to create a multi-line label since the TextFormatting.NewLine is not supported in the label of the web map. Later this year there will be a rewrite with the new API of the map viewer and that will enable multi-line labels. (Not sure though as to why the result is shown on a single line in the Arcade window).

In my example what I did to get the "multiline label" was duplicating the layer and define two different alignments for each layer, the first line in the first layer using top and the second line based on the second layer using the bottom alignment.

KamillePreto
Occasional Contributor II

I see! That makes sense.

Thank you for the response.

Andy_Morgan
New Contributor III

Later this year there will be a rewrite...

Forgive my somewhat off-topic question, but does this include the 4.x Javascript API?  I'm not clear if the JS API 4 relates directly to the "map viewer API". In other words, will MapImageLayer eventually support Arcade expressions (and therefore TextFormatting.NewLine)? 

Currently the LabelClass labelExpressionInfo : { expression: .... } is only supported through FeatureLayers but I really need it to be available through MapImageLayer. 

0 Kudos