Select to view content in your preferred language

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

62068
10
Jump to solution
02-21-2021 06:56 PM
Labels (1)
LeandraGordon
Frequent Contributor

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 Esteemed 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

10 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
Frequent Contributor

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

0 Kudos
jcarlson
MVP Esteemed 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
LeandraGordon
Frequent Contributor

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
by Anonymous User
Not applicable

" 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 Esteemed 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
ahargreaves_FW
Frequent Contributor

So why does this work fine in Pro, but not in mapviewer at 10.9.1?

ahargreaves_FW_0-1679952405613.png

 

0 Kudos
jcarlson
MVP Esteemed Contributor

Your string doesn't have any line break characters in it?

Try "line one\nline two\nline three". Or use a template literal!

jcarlson_0-1679952895776.png

 

- Josh Carlson
Kendall County GIS
0 Kudos
ahargreaves_FW
Frequent Contributor

Apologies, I wasn't very clear what I was asking. This documentation states to specify a font, size or alignment I should use something like: 

"<FNT name = 'Roboto' style = 'Regular' size = '12' horizontal = 'center'>" + $feature.attribute "</FNT>"

But the <FNT> tags end up included in the label itself.

ahargreaves_FW_0-1680009191544.png

This forum post discusses the same issue. Though it's now 3 yrs old it appears the problem still persists that Arcade is not universally applicable anywhere in the Esri platform.