Click or drag to resize

TextSymbol Class

Text symbol used to draw text as a marker symbol
Inheritance Hierarchy

Namespace:  Esri.ArcGISRuntime.Symbology
Assembly:  Esri.ArcGISRuntime (in Esri.ArcGISRuntime.dll) Version: 100.7.0.0
Syntax
public class TextSymbol : MarkerSymbol

The TextSymbol type exposes the following members.

Constructors
  NameDescription
Public methodCode exampleTextSymbol
Initializes a new instance of the TextSymbol class.
Public methodTextSymbol(String, Color, Double, HorizontalAlignment, VerticalAlignment)
Initializes a new instance of the TextSymbol class.
Top
Properties
  NameDescription
Public propertyAngle
Gets or sets the rotation angle.
(Inherited from MarkerSymbol.)
Public propertyAngleAlignment
Gets or sets the rotation angle alignment. Default value is Screen
(Inherited from MarkerSymbol.)
Public propertyBackgroundColor
Gets or sets the color for the text symbol background.
Public propertyCode exampleColor
Gets or sets the color for the text symbol.
Public propertyFontDecoration
Gets or sets the type of font decoration for the text symbol.
Public propertyFontFamily
Gets or sets the font family of the text symbol.
Public propertyFontStyle
Gets or sets the font style of the text symbol.
Public propertyFontWeight
Gets or sets the font weight of the text symbol.
Public propertyCode exampleHaloColor
Gets or sets the halo color for the text symbol.
Public propertyCode exampleHaloWidth
Gets or sets the halo width on the text symbol.
Public propertyHorizontalAlignment
Gets or sets the horizontal alignment of the text symbol.
Public propertyKerningEnabled
Gets or sets the boolean value indicating whether to adjust the spacing between individual characters in the text.
Public propertyCode exampleLeaderOffsetX
Gets or sets the leader offset X of the marker symbol.
(Inherited from MarkerSymbol.)
Public propertyLeaderOffsetY
Gets or sets the leader offset Y of the marker symbol.
(Inherited from MarkerSymbol.)
Public propertyCode exampleOffsetX
Gets or sets the X offset.
(Inherited from MarkerSymbol.)
Public propertyCode exampleOffsetY
Gets or sets the Y offset.
(Inherited from MarkerSymbol.)
Public propertyCode exampleOutlineColor
Gets or sets the outline color for the text symbol.
Public propertyOutlineWidth
Gets or sets the outline width on the text symbol.
Public propertyRotationType Obsolete.
Gets or sets the rotation type of the marker symbol.
(Inherited from MarkerSymbol.)
Public propertyCode exampleSize
Gets or sets the font size of the text symbol.
Public propertyCode exampleText
Get or sets the text of the text symbol.
Public propertyVerticalAlignment
Gets or sets the vertical alignment of the text symbol.
Top
Methods
  NameDescription
Public methodClone
Clones this instance of Symbol and its members.
(Inherited from Symbol.)
Public methodCode exampleCreateSwatchAsync(Double)
Creates a swatch image of this symbol using the default size and a transparent background.
(Inherited from Symbol.)
Public methodCreateSwatchAsync(Color, Double)
Creates a swatch image of this symbol, using the default sizing and a transparent background.
(Inherited from Symbol.)
Public methodCreateSwatchAsync(Int32, Int32, Double, Color)
Creates a swatch image of this symbol, scaled to fit the specified dimensions.
(Inherited from Symbol.)
Public methodCreateSwatchAsync(Int32, Int32, Single, Color, Geometry)
Creates a swatch image of this symbol, with the specified image size, dpi, background color, and geometry.
(Inherited from Symbol.)
Public methodToJson
Returns the json representation of the symbol
(Inherited from Symbol.)
Top
Events
  NameDescription
Public eventPropertyChanged
Occurs when a property value changes.
(Inherited from Symbol.)
Top
Examples

WPF

Example Name: GetElevationAtPoint

Get the elevation for a given point on a surface in a scene.

Code example screen shot.

C#
// Copyright 2019 Esri.
// 
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
// You may obtain a copy of the License at: http://www.apache.org/licenses/LICENSE-2.0
// 
// Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific
// language governing permissions and limitations under the License.

using Esri.ArcGISRuntime.Geometry;
using Esri.ArcGISRuntime.Mapping;
using Esri.ArcGISRuntime.Symbology;
using Esri.ArcGISRuntime.UI;
using System;
using System.Diagnostics;
using System.Drawing;
using System.Windows;

namespace ArcGISRuntime.WPF.Samples.GetElevationAtPoint
{
    [ArcGISRuntime.Samples.Shared.Attributes.Sample(
        "Get elevation at a point",
        "Map",
        "Retrieve the elevation of a point on a surface",
        "Tap anywhere on the surface to get the elevation at that point. Elevation is reported in meters since the scene view is in WGS84.")]
    public partial class GetElevationAtPoint
    {
        // URL of the elevation service - provides elevation component of the scene.
        private readonly Uri _elevationUri = new Uri("http://elevation3d.arcgis.com/arcgis/rest/services/WorldElevation3D/Terrain3D/ImageServer");

        // Starting point of the observer.
        private readonly MapPoint _observerPoint = new MapPoint(83.9, 28.42, SpatialReferences.Wgs84);

        // Graphics overlay.
        private GraphicsOverlay _overlay;

        // Surface (for elevation).
        private Surface _baseSurface;

        // Create symbols for the text and marker.
        private SimpleMarkerSceneSymbol _elevationMarker;
        private TextSymbol _elevationTextSymbol;
        private readonly Graphic _elevationTextGraphic = new Graphic();

        public GetElevationAtPoint()
        {
            InitializeComponent();

            // Create the UI, setup the control references and execute initialization.
            Initialize();

            // Handle taps on the scene view for getting elevation.
            MySceneView.GeoViewTapped += SceneViewTapped;
        }

        private void Initialize()
        {
            // Create the camera for the scene.
            Camera camera = new Camera(_observerPoint, 20000.0, 10.0, 70.0, 0.0);

            // Create a scene.
            Scene myScene = new Scene(Basemap.CreateImageryWithLabels())
            {
                // Set the initial viewpoint.
                InitialViewpoint = new Viewpoint(_observerPoint, 1000000, camera)
            };

            // Create the marker for showing where the user taps.
            _elevationMarker = SimpleMarkerSceneSymbol.CreateCylinder(Color.Red, 10, 750);

            // Create the text for displaying the elevation value.
            _elevationTextSymbol = new TextSymbol("", Color.Red, 20, Esri.ArcGISRuntime.Symbology.HorizontalAlignment.Center, Esri.ArcGISRuntime.Symbology.VerticalAlignment.Middle);
            _elevationTextGraphic.Symbol = _elevationTextSymbol;

            // Create the base surface.
            _baseSurface = new Surface();
            _baseSurface.ElevationSources.Add(new ArcGISTiledElevationSource(_elevationUri));

            // Add the base surface to the scene.
            myScene.BaseSurface = _baseSurface;

            // Graphics overlay for displaying points.
            _overlay = new GraphicsOverlay
            {
                SceneProperties = new LayerSceneProperties(SurfacePlacement.Absolute)
            };
            MySceneView.GraphicsOverlays.Add(_overlay);

            // Add the scene to the view.
            MySceneView.Scene = myScene;
        }

        private async void SceneViewTapped(object sender, Esri.ArcGISRuntime.UI.Controls.GeoViewInputEventArgs e)
        {
            try
            {
                // Remove this method from the event handler to prevent concurrent calls.
                MySceneView.GeoViewTapped -= SceneViewTapped;

                // Check that the point is on the surface.
                if (e.Location != null)
                {
                    // Clear any existing graphics from the graphics overlay.
                    _overlay.Graphics.Clear();

                    // Get the elevation value.
                    double elevation = await _baseSurface.GetElevationAsync(e.Location);

                    // Set the text displaying the elevation.
                    _elevationTextSymbol.Text = $"{Math.Round(elevation)} m";
                    _elevationTextGraphic.Geometry = new MapPoint(e.Location.X, e.Location.Y, e.Location.Z + 850);

                    // Add the text to the graphics overlay.
                    _overlay.Graphics.Add(_elevationTextGraphic);

                    // Add the marker indicating where the user tapped.
                    _overlay.Graphics.Add(new Graphic(e.Location, _elevationMarker));
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
                MessageBox.Show(ex.Message, "Sample error");
            }
            finally
            {
                // Re-add to the event handler.
                MySceneView.GeoViewTapped += SceneViewTapped;
            }
        }
    }
}
XAML
<UserControl
    x:Class="ArcGISRuntime.WPF.Samples.GetElevationAtPoint.GetElevationAtPoint"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:esri="http://schemas.esri.com/arcgis/runtime/2013">
    <Grid>
        <esri:SceneView x:Name="MySceneView" />
        <Border Style="{StaticResource BorderStyle}">
            <TextBlock Text="Tap to find the elevation for a point."
                       TextAlignment="Center" TextWrapping="Wrap" FontWeight="SemiBold" />
        </Border>
    </Grid>
</UserControl>
See Also
Additional Examples
Hyperlink to ExampleDescription
DisplayGridDisplay coordinate system grids including Latitude/Longitude, MGRS, UTM and USNG on a map view. Also, toggle label visibility and change the color of grid lines and grid labels.
GetElevationAtPointGet the elevation for a given point on a surface in a scene.
OfflineRoutingSolve a route on-the-fly using offline data.
RouteAroundBarriersFind a route that reaches all stops without crossing any barriers.