Arcade labeling - NewLine and stacked labels

1002
3
11-11-2019 07:52 AM
JodieGosselin1
New Contributor III

I am trying to find a way to make labels with line breaks in my web mapping. As of right now, everything I read on the GeoNet as well as GitHub says that the NewLine function is still not supported by ESRI and is not available in map view.

However, I keep coming across this ArcGIS for developers article about using the concatenate function with NewLine: 

https://developers.arcgis.com/javascript/latest/sample-code/labels-multiline/index.html

Is the script featured in the article above a way that I can create multi-line labels in AGOL? Does anyone have an update on this, or have you tried using Concatenate/NewLine without first defining a variable, etc.?

Thanks!

Tags (2)
3 Replies
JaredPilbeam2
MVP Regular Contributor

I'm coming across the same issues. I've read Arcade doesn't support newline in 3.x JSAPI and is supposed to be supported in 4.x JSAPI: https://community.esri.com/thread/187776-arcade-text-constant-for-textformattingnewline-is-adding-sp... 

I've copied the Arcade syntax from the same page you're referring to in an attempt to create newline labels. In the Arcade window the script looks valid. But, it does not change the label in the web map??

XanderBakker
Esri Esteemed Contributor

Hi Jodie Gosselin  and Jared Pilbeam ,

The only way to get multiline labels through configuration in a web map in AGOL at this moment is configure the Arcade expression in the current web map and open the map in the beta map viewer in AGOL. This is build o the 4.X JS API and will show the labels on multiple lines. 

MichaelKellyTeck
Occasional Contributor

TextFormatting.NewLine will only work with 4.x of the JavaScript API. The current Map Viewer, along with many apps including Web AppBuilder and as of 2019 Operations Dashboard, are written in 3.x. In these apps new lines in labels are not honored.

However, the Map Viewer Beta, along with Experience Builder and 'newer apps' are written in 4.x and therefore honor new lines. The Map Viewer Beta does not have an option to configure labels -  it is currently on the roadmap. In the meantime, you can configure labels with new lines in the standard Map Viewer. They will not display in the Map Viewer as it is written in 3.x. However they will be saved in the Web Map and when you view the Web Map through a 4.x app the labels will appear as you have configured.