Is there an AGOL equivalent to the Label Stacking options provided in ArcGIS Pro?
Or is there a way to achieve this using Arcade, since AGOL does accept Label Expressions.
Here's a script that splits lines at a set character length (maxLength)
var maxlength = 15; var myArray = split($feature["YourFieldNameHere"], " "); var string; var lineArray = []; var lineLength = 0; for (var k in myArray) { if (count(myArray[k]) <= maxlength) { if (lineLength <= maxlength) { Push(lineArray, trim(myArray[k])) lineLength += count(trim(myArray[k]) + (count(lineArray) - 1)) if (lineLength > maxlength) { string += Concatenate(lineArray, " ") + TextFormatting.NewLine; lineArray = []; lineLength = 0; } } } else { if (lineLength > 0) { string += Concatenate(lineArray, " ") + TextFormatting.NewLine + trim(myArray[k]) + TextFormatting.NewLine; lineLength = 0; lineArray = [] } else { string += trim(myArray[k]) + TextFormatting.NewLine; } } } if (lineLength > 0) string += Concatenate(lineArray, " "); return string;
Thanks, @KenBuja! This is exactly what I was hoping for.
It's not completely obvious but it's there.
var words = Split($feature["YourFieldNameHere"], " ") return Concatenate(words, TextFormatting.NewLine)
Starter for ten, insert your field name and adjust to suit.
Membros conectados podem postar, seguir atualizações e mais. Novo aqui? Registre uma conta gratuita.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.