Hi all,
Do anyone know if it is possible to do any customization to a text field in a layer for instance in the Map Viewer in an Enterprise environment?
What we have is a lot of "Comments" fields in layers, and a lot of them will actually contain a lot of information. But it is very difficult to read, because it is just in one long string...
Is it for instance possible to do line shift in a text field? Through some Arcade? It could both be in the pop-up after you've entered it, but also in the text field itself, while you are entering information. Here it is also difficult to see where you are entering what, when there is too much text.
So any suggestion to better view the text is appreciated 🙂
Thanks
Solved! Go to Solution.
Manual linebreaks
You can insert linebreaks into a text field by pressing Shift + Enter.
Automatic linebreaks
Using Arcade, you can automatically insert linebreaks. You can use these expressions in popups (somehow it does not work in the Pro popup...), in attribute rules, or in the field calculator.
Option 1: line break after certain symbols
var symbols = [".", ";"]
var t = $feature.TextField
for(var i in symbols) {
var s = symbols[i]
var lbs = s + "\n"
t = Replace(t, lbs, s) // remove manual breaks to avoid empty lines
t = Concatenate(Split(t, s), lbs)
}
return t
Option 2: line break after a certain length
var words = Split($feature.TextField, " ")
var max_length = 20
var t = ""
var l = 0
for(var i in words) {
var word = words[i] + " "
l += Count(word)
if(l <= max_length) {
t += word
} else {
t += TextFormatting.NewLine + word
l = 0
}
}
return t
Here's how the two options look in a MapViewer popup:
Manual linebreaks
You can insert linebreaks into a text field by pressing Shift + Enter.
Automatic linebreaks
Using Arcade, you can automatically insert linebreaks. You can use these expressions in popups (somehow it does not work in the Pro popup...), in attribute rules, or in the field calculator.
Option 1: line break after certain symbols
var symbols = [".", ";"]
var t = $feature.TextField
for(var i in symbols) {
var s = symbols[i]
var lbs = s + "\n"
t = Replace(t, lbs, s) // remove manual breaks to avoid empty lines
t = Concatenate(Split(t, s), lbs)
}
return t
Option 2: line break after a certain length
var words = Split($feature.TextField, " ")
var max_length = 20
var t = ""
var l = 0
for(var i in words) {
var word = words[i] + " "
l += Count(word)
if(l <= max_length) {
t += word
} else {
t += TextFormatting.NewLine + word
l = 0
}
}
return t
Here's how the two options look in a MapViewer popup:
Hi Johannes,
I'm using the arcade option 1 and when I click Test it looks perfect. However when I open my pop-up, the text field hasn't changed. It is as if the expression isn't being read... Is there a step I'm missing? I've only changed the name of the field and then clicked ok.
Hi Johannes,
Thnak you so much for your input - I will get straight on it, and might have some follow up 🙂