This project is read-only.

Is linebreaks supported in labels?

Jun 25, 2014 at 10:37 AM
I'm using labels with my map, and they are shown with the exception that they haven't any linebreaks. So some of my labels are saying "Hello\nWorld!", where \n should be a linebreak in this case.

Is linebreak supported in some way?
Jun 25, 2014 at 10:57 AM
Just tried it - linebreaks (\r\n or \n) works fine with map labels.
Jun 25, 2014 at 12:28 PM
It doesn't work for me.

My code:
Dim ls As New LabelSymbolizer()
ls.LabelAngleField = "VINKEL"
ls.UseLabelAngleField = True

Me.uiMap.AddLabels(layer, "[DESCRIPTIO]", "", ls, 500)
Jun 25, 2014 at 2:03 PM
Is this text "ID:648013\nkW: 11\nFami....." is content of "DESCRIPTIO" field?
Jun 25, 2014 at 2:34 PM

And I'm using DotSpatial 1.6 via nuget.
Jun 26, 2014 at 7:33 AM
Ok, i've created simple application using DS1.6 and it also shows line breaks. Maybe something wrong with your data? Please share your data, so i can check it.
Jun 26, 2014 at 10:14 AM
Here's my data: (click on File --> Download, or hit Ctrl+S once you opened the link).
Jun 26, 2014 at 11:43 AM
Edited Jun 26, 2014 at 12:07 PM
your field values are something like this:
currValue = "ID: 648044\\nkW: 74\\nSunnanvinden Trading AB\\nFallvindsgatan 4\\nKvдllsvinden 2"
if you want linebreaks, then values should be:
currValue = "ID: 648044\nkW: 74\nSunnanvinden Trading AB\nFallvindsgatan 4\nKvдllsvinden 2"
i.e. you need to replace all double backslashes with single ones, because in C# & VB.NET "\\" mean character "\".
Marked as answer by mogikanin on 6/26/2014 at 5:21 AM
Jun 26, 2014 at 12:11 PM
This is strange, when I open the .shp file in AutoCAD and take a look at the DataTable, there are no double backslashes.
Jun 26, 2014 at 12:14 PM
but probably you see "\n". But new line symbol is nonprinting and you should see nothing.
Jun 26, 2014 at 12:55 PM
I'm sorry, but I can't find anything wrong with my data. Here are pictures from another program, QGIS.

This first screenshot shows the raw data and output.

This second screenshot shows when I have added \n as a linebreak.

Are you sure that you get my data to work on your computer? Are you sure that DotSpatial doesn't add a second backslash to my data? Because I really can't see anything wrong with my data.
Jun 26, 2014 at 1:36 PM
Edited Jun 26, 2014 at 1:37 PM
Yes, i'm sure. Again, new line breaks is nonprinting symbol, so in any program you should see nothing (or new line). But you see "\n" and dotspatial shows to you the same. If you want to show linebreaks, then you should replace "\\" to "\" - for that you can create a simple program using DotSpatial.

But now your data contains two characters '\' and 'n', but should contains only one non printing symbol '\n' (char code 10).