Hi all,
I'm new to working with label expressions in ArcGIS Pro and I was hoping for some help. The expression I'm working with is as follows (VBScript):
[full_name] + " (Z:" & [zone] & " R:" & [rank_id] &")"
I realize my syntax and labeling structure is messy, but it's been getting the job done. The label is displaying a client name followed by their zone and rank numbers in parenthesis. Example: ExampleName (Z:1 R:10) The problem I'm having occurs when a longer client name forces what I have in parenthesis on to two different lines when I have label stacking enabled.
Is there a way to ensure that my information inside the parenthesis always stays together on the same line?
Any help is appreciated!
Solved! Go to Solution.
A less elegant option (without code) would be to simply change the label engine from Maplex to Standard Label Engine by un-selecting the Use Maplex Label Engine under the more options.
This should ensure all labels are on one line.
A less elegant option (without code) would be to simply change the label engine from Maplex to Standard Label Engine by un-selecting the Use Maplex Label Engine under the more options.
This should ensure all labels are on one line.
This seems to be solved my issue:
I turned off Maplex Label Engine and added \n before my parenthesis to push this portion onto to the second line. [full_name] + "\n (Z:" & [zone] & " R:" & [rank_id] &")"
There must be a way to format this in Maplex, but using a line break was creating too large of a break for my desired label appearance. For now, the less elegant option does the job.
Hi Brandon,
This problem may no longer be relevant for you, but just in case it is: the issue is that maplex has the option to specify stacking characters, and the space character is a stacking separator by default, so it splits on any space it sees fit.
You could remove the space as a stacking separator and choose an open bracket character for example, with visibility on and split after checked off.
However, this won't help you if you still want it to stack on space characters in other parts of your expression. For that, you can use non-breaking space characters.
You can replace regular spaces in part of your expression with non-breaking space character (U+00A0). For example:
$feature.full_name + " (Z:" + $feature.zone + "\u00A0" + "R:"+ $feature.rank_id +")"
Or if you have regular spaces in your fields and don't want them to stack, you could find and replace them with nbsp in a section:
$feature.full_name+ " " + replace("(Z:" + $feature.zone + " R:"+ $feature.rank_id +")", " ", "\u00A0")
Maplex will not split on these non breaking space characters.
Or as a third option, you can hard code your new line character, and disabling stacking as a fitting strategy
$feature.full_name + TextFormatting.Newline + "(Z:" + $feature.zone + " R:"+ $feature.rank_id +")"
All the examples above are using Arcade, but will work just as well in any other parser. For VBScript make sure you use + vbnewline + instead of TextFormatting.Newline to ensure you have the correct type of line feed character.
Hope that helps!
Ciara
Hi @CiaraRowland-Simms , if I disable stacking my label does not use the TextFormatting.Newline? Maybe a bug? I'm using Pro 2.9.3.
I think this is the most correct answer. You may wish for your labels to use Maplex rules overall for line breaks, but you just don't want it to occur in this specific place. In my case, I wanted to separate a date and time with a space, but always keep them on the same line, however, I wanted Maplex rules to figure out the rest of the line break rules.
Hi @Anonymous User,
Would you be able to send over what placement strategy you have on this label? Or send the layer file for me to take a look? Some types such as street labeling and contour deliberately ignore any new lines in the expression, so I'm wondering if you might be using one of those.
All the best,
Ciara
Hi @CiaraRowland-Simms, here are the screenshots of the label position tabs.
Let me know if that helps.
Thank you!
Hi @Anonymous User ,
Thanks that's great! My suspicion based on those properties is that Never remove (place overlapping) on the Conflict Resolution tab is causing the issue. That property is really a last resort to get text on the map when there isn't enough room. Would you be able to see if turning it off resolves your stacking issue?
Ciara
Hi @CiaraRowland-Simms , no that didn't change it. It works for some of the labels but not this one.