Show labels on layer 3D

View inWPFWinUIMAUIView on GitHub

Display custom labels in a 3D scene.

Show labels on layer in 3D

Use case

Labeling features is useful to visually display information or attributes on a scene. For example, city officials or maintenance crews may want to show installation dates of features of a gas network.

How to use the sample

Pan and zoom to explore the scene. Notice the labels showing installation dates of features in the 3D gas network.

How it works

To open a web scene from a portal item:

  1. Create a Scene from a URL, then load.
  2. After loading is complete, obtain the gas layer from the scene's operational layers.
  3. From the gas layer, find the main gas sublayer.
  4. Create a TextSymbol to use for displaying the label text.
  5. Create a LabelDefinition using an ArcadeLabelExpression.
  6. Add the definition to the feature layer's labelDefinitions list.

Relevant API

  • ArcadeLabelExpression
  • LabelDefinition
  • Scene
  • SceneView

About the data

This sample shows a New York City infrastructure scene hosted on ArcGIS Online.

Tags

3D, labeling, scene, web scene

Sample Code

ShowLabelsOnLayer3D.xamlShowLabelsOnLayer3D.xamlShowLabelsOnLayer3D.xaml.cs
Use dark colors for code blocksCopy
         
1
2
3
4
5
6
7
8
9
<UserControl
    x:Class="ArcGIS.WinUI.Samples.ShowLabelsOnLayer3D.ShowLabelsOnLayer3D"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:esriUI="using:Esri.ArcGISRuntime.UI.Controls">

    <esriUI:SceneView x:Name="MySceneView" />

</UserControl>

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.