TextSymbol BackgroundColor not working with static rendering

1874
0
10-16-2015 08:11 AM
ChrisSmith10
New Contributor II

I have noticed that the BackgroundColor property has no affect when rendering is set to static for a graphics layer. The BackgroundColor property works if the rendering mode is dynamic, however, the TextSymbol placement changes. Screenshots and code below (see line 49)

Static Rendering

Screenshot 2015-10-16 11.09.08.png

Dynamic Rendering

Screenshot 2015-10-16 11.08.03.png

private async void MeasureLocationAsync(object sender, RoutedEventArgs e)
    {
      while (true)
      {
        // get or create graphics layer to display user measurement objects
        var measureLayer = (GraphicsLayer) MyMapView.Map.Layers[MeasureLayerID];
        if (measureLayer == null)
        {
          measureLayer = new GraphicsLayer {ID = MeasureLayerID};
          measureLayer.RenderingMode = GraphicsRenderingMode.Static;
          MyMapView.Map.Layers.Add(measureLayer);
        }

        var taskLoadLayer = MyMapView.LayersLoadedAsync(new List<Layer> {measureLayer});
        var taskDrawShape = MyMapView.Editor.RequestPointAsync();
        try
        {
          await Task.WhenAll(taskLoadLayer, taskDrawShape);
        }
        catch (TaskCanceledException)
        {
          // editor operation was cancelled. break out of this
          return;
        }

        var point = taskDrawShape.Result;
        var wgs84Location = (MapPoint)GeometryEngine.Project(point, SpatialReferences.Wgs84);

        // clear existing items from measurement layer
        measureLayer.Graphics.Clear();

        // create symbol
        var markerSymbol = new SimpleMarkerSymbol
        {
          Color = Colors.Orange,
          Size = 16,
          Outline = new SimpleLineSymbol()
          {
            Color = Colors.Black,
            Width = 3
          }
        };
        var symbolGraphic = new Graphic(point, markerSymbol);

        // create text label
        var textSymbol = new TextSymbol
        {
          Color = Colors.Orange,
          BackgroundColor = Colors.Black, // this doesn't work when rendering mode is static, bug in esri?
          XOffset = 10,
          YOffset = 10,
          HorizontalTextAlignment = HorizontalTextAlignment.Right,
          Font = new SymbolFont(MeasurePostionButton.FontFamily.Source, 24, SymbolFontStyle.Normal, SymbolTextDecoration.None, SymbolFontWeight.Bold),
          Text = $"{wgs84Location.X}, {wgs84Location.Y}"
        };
        var textGraphic = new Graphic(point, textSymbol);

        measureLayer.Graphics.Add(symbolGraphic);
        measureLayer.Graphics.Add(textGraphic);
      }
    }
0 Replies