mtakiti

How to do multiline textsymbol or textsymbol with linebreaks?

Discussion created by mtakiti on Sep 26, 2012
Latest reply on Sep 21, 2018 by jawest1
I have a text symbol like the following:


            var textSymbol = new esri.symbol.TextSymbol(
              "Row 1 \n Row 2 \n Row 3",
              font, new dojo.Color([0, 0, 0])
            );
            var labelPointGraphic = new esri.Graphic(labelPoint,textSymbol);
            map.graphics.add(labelPointGraphic);

I want to be able to separate out the Row1, Row2, and Row3 into separate lines, but it appears that having "\n" does not work andstill shows up on the same line. If there is not a simple way to have a single textSymbol with multiple lines, then is there some way I can create two textSymbols such that the second is offset to be just below first text symbol? Something like:

            var textSymbol = new esri.symbol.TextSymbol(
              "Row 1",
              font, new dojo.Color([0, 0, 0])
            );
            var anothertextSymbol = new esri.symbol.TextSymbol(
              "Row 2",
              font, new dojo.Color([0, 0, 0])
            );

            var labelPointGraphic = new esri.Graphic(labelPoint,textSymbol);
            map.graphics.add(labelPointGraphic);
            var labelPointGraphic = new esri.Graphic(labelPoint,anothertextSymbol).offset("someamount", "someamount");
            map.graphics.add(labelPointGraphic);

Note that I have tried using offset, but it appears to space them out way more than I would like and the gaps appear to widen whenever I zoom in or out. Feels like this should be simple...

Please help.

Outcomes