0

I have an attribute field [NOTE] that contains very long strings - often 255 characters - usually consisting of multiple sentences.

I'd like to be able to use ArcMap's MapTips with some form of wrapping, because without it the MapTip text usually runs off of the map pane, obscuring important parts of the note.

Is it possible to do this in the Advanced box using the Python parser? I

tried variations of a python function textwrap.wrap([NOTE]) to no avail.

enter image description here

2

This is a bit crude but will do the job...I'm sure someone will be able to produce some more efficient Python code. It would obviously be better to wrap at a space rather than the middle of the word but this demonstrates that the concept is possible.

def FindLabel ( [Note] ):
  txt = [Note]
  txtList = []
  txtList.append(txt[:50])
  txtList.append(txt[50:100])
  txtList.append(txt[100:150])
  txtList.append(txt[150:200])
  txtList.append(txt[200:255])
  return "\n".join(txtList)

enter image description here enter image description here

  • 1
    This is similar, not limited to 255 though, n = 50 txt = [Note] textList = ([txt[i:i+n] for i in range(0, txt(line), n)]) return "\n".join(txtList) – JamesLeversha Nov 14 '18 at 21:25
  • I had to make one change to James' comment to get it to work... txtList = ([txt[i:i+n] for i in range(0, len(txt), n)]) – Dan Jun 24 at 2:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.