TextSymbol with Text that contains a new line locks up map

2488
4
10-20-2014 06:55 AM
ChrisSanter
New Contributor

New lines worked fine in 10.2.3, but lock up the map control in 10.2.4

It can be recreated using the samples, by editing TextSymbol.xaml.cs, and adding the following line of code to AcceptPointsAsync:

...

var symbol = _symbols[symbolCombo.SelectedIndex];

symbol.Text += Environment.NewLine + "Second line";

graphicsOverlay.Graphics.Add(new Graphic(point, symbol));

...

Is there a workaround to allow text across multiple line?

Thanks!

0 Kudos
4 Replies
JenniferNery
Esri Regular Contributor

Hi Chris,

I can't seem to reproduce the issue with 10.2.4. I am using the following code though:

Text = "a\nb\nc" // where '\n' places the next sets of characters in new line.

             xmlns:esri="http://schemas.esri.com/arcgis/runtime/2013">

    <Grid>

        <esri:MapView x:Name="MyMapView">

            <esri:Map >

                <esri:ArcGISTiledMapServiceLayer ServiceUri="http://services.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer" />

            </esri:Map>

            <esri:MapView.GraphicsOverlays>

                <esri:GraphicsOverlay ID="Overlay" />

            </esri:MapView.GraphicsOverlays>

        </esri:MapView>

        <Button VerticalAlignment="Top"

                HorizontalAlignment="Center"

                Content="Add"

                Click="Button_Click" />

    </Grid>

        private async void Button_Click(object sender, RoutedEventArgs e)

        {

            string message = null;

            try

            {

                var mp = await MyMapView.Editor.RequestPointAsync();

                var g = new Graphic() { Geometry = mp, Symbol = new TextSymbol() { Text = "a\nb\nc" } };

                var o = MyMapView.GraphicsOverlays["Overlay"] as GraphicsOverlay;

                o.Graphics.Add(g);

            }

            catch (Exception ex)

            {

                message = ex.Message;

            }

            if (!string.IsNullOrWhiteSpace(message))

                MessageBox.Show(message);

        }

0 Kudos
DavePriest
New Contributor

Hi Jennifer,

Environment.NewLine is actually "\r\n" so if you substitute your example thusly you will get the same behavior:

Replace

     var g = new Graphic() { Geometry = mp, Symbol = new TextSymbol() { Text = "a\nb\nc" } };

with

     var g = new Graphic() { Geometry = mp, Symbol = new TextSymbol() { Text = "a" + Environment.NewLine + "b" + Environment.NewLine + "c" } };

We'll have to confirm but it appears that we have to use '\n" for our new lines, and hence, our workaround.

Thanks.

0 Kudos
ChrisSanter
New Contributor

Thanks for the response Jennifer.

I can confirm that the workaround suggested by Dave works (using "\n" instead of Environment.NewLine). However, I would like to suggest that, by convention in the Windows OS, that "\r\n" or Environment.NewLine is the correct representation of a new line (in Linux "\n" would be correct), and probably should not cause the map to lock up!

0 Kudos
JenniferNery
Esri Regular Contributor

Hi Dave and Chris,

Thank you both for your feedback. I will log the issue. You're both right that map should not be unresponsive. I will check whether Environment.Newline could be supported in the future.

Thanks.

Jennifer

0 Kudos