How to include a Carriage Return or NewLine into an ARCADE Label expression?

4354
6
Jump to solution
02-21-2021 06:56 PM
Labels (1)
LeandraGordon
Occasional Contributor II

How can I insert newline characters in an Arcade expression in ArcGIS Enterprise, the following:

'Rural SI VBP: ' +$feature.AllData_Rural_Site_Influences__VBP_
+ textformatting.NewLine
+ ' SI Non VBP: ' +$feature.AllData_Site_Influences__Non_VBP_
+ textformatting.newline

seems to be ignored in ArcGIS Enterprise. 
The inital maps are being prepared in ArcGIS Pro 2.4 so if there is a way we could do this there and have the labels show up in Portal that would work for us too.

I understand from previous questions that textformatting.NewLine isn't supported? But it is included in the documentation here: https://pro.arcgis.com/en/pro-app/latest/help/mapping/text/text-formatting-tags.htm

This is how it looks for us currently in Mapinfo:

LeandraGordon_0-1613962360841.png

 

Tags (3)
1 Solution

Accepted Solutions
jcarlson
MVP Frequent Contributor

If you are rendering your label in a JS 3.x map (like the current Map Viewer), TextFormatting.NewLine and "\n" are both ignored.

In a JS 4.x (Map Viewer Beta, certain Configurable Apps), both are valid ways of adding a new line.

Here's a layer of ours with multiline labels, first in a JS 3.x map:

jcarlson_1-1614000666436.png

And then in JS 4.x:

jcarlson_2-1614000773967.png

 

What version of Portal are you on? If you're at 10.8 or later, you can also create Hosted Map Image Layers that can take advantage of all the advanced labeling and symbology of Pro, but are based on a hosted feature layer. Works just the same in either map viewer, too.

- Josh Carlson
Kendall County GIS

View solution in original post

6 Replies
ManishPatel
Esri Contributor

Hi @LeandraGordon ,

 

TextFormatting.NewLine this should work, I just tried and it works for me. You might want to check from the list of the constant functions and test it.

Cheers,
Manish
LeandraGordon
Occasional Contributor II

Hi Manish - what version of ArcGIS Pro and Portal are you using?

0 Kudos
jcarlson
MVP Frequent Contributor

If you are rendering your label in a JS 3.x map (like the current Map Viewer), TextFormatting.NewLine and "\n" are both ignored.

In a JS 4.x (Map Viewer Beta, certain Configurable Apps), both are valid ways of adding a new line.

Here's a layer of ours with multiline labels, first in a JS 3.x map:

jcarlson_1-1614000666436.png

And then in JS 4.x:

jcarlson_2-1614000773967.png

 

What version of Portal are you on? If you're at 10.8 or later, you can also create Hosted Map Image Layers that can take advantage of all the advanced labeling and symbology of Pro, but are based on a hosted feature layer. Works just the same in either map viewer, too.

- Josh Carlson
Kendall County GIS

View solution in original post

LeandraGordon
Occasional Contributor II

Hi Josh,

Hosted Map Image Layers won't work for us as we are creating ArcGIS Pro maps on the fly from excel and loading them into ArcGIS Enterprise as Individual Map Image Layers. We create a couple a day during our peak season as the maps are used as an Audit tool for our data.
The problem starts in ArcGIS Pro when TextFormatting.NewLine is ignored.
Note that I've found some other info here: https://community.esri.com/t5/developers-questions/arcade-text-constant-for-textformatting-newline-i...

0 Kudos
AndreaB
Occasional Contributor III

" TextFormatting.NewLine - Inserts a new line, or line break, into the text. Multi-line labels are NOT supported in the ArcGIS API 3.x for JavaScript nor in the ArcGIS Online map viewer" I tried "\n" and "<br />" and those both don't work.

So....how do I get multi-line labels in ArcGIS Online Classic Map viewer? @ManishPatel @KoryKramer  do you know?

jcarlson
MVP Frequent Contributor

As mentioned above, you'll only be able to get this with a Map Image Layer or a Hosted Map Image Layer. There's no way to get a Feature Service to have multi-line labels in the Classic Map Viewer.

- Josh Carlson
Kendall County GIS