Distance measurement analysis

View inAndroidFormsUWPWPFWinUIiOSView on GitHub

Measure distances between two points in 3D.

Image of distance measurement analysis

Use case

The distance measurement analysis allows you to add to your app the same interactive measuring experience found in ArcGIS Pro, City Engine, and the ArcGIS API for JavaScript. You can set the unit system of measurement (metric or imperial). The units automatically switch to one appropriate for the current scale.

How to use the sample

Choose a unit system for the measurement. Click any location in the scene to start measuring. Move the mouse to an end location, and click to complete the measurement. Click a new location to clear and start a new measurement.

How it works

  1. Create an AnalysisOverlay object and add it to the analysis overlay collection of the SceneView object.
  2. Specify the start location and end location to create a LocationDistanceMeasurement object. Initially, the start and end locations can be the same point.
  3. Add the location distance measurement analysis to the analysis overlay.
  4. The MeasurementChanged event will be raised if the distances change. You can get the new values for the DirectDistance, HorizontalDistance, and VerticalDistance from the event arguments.

Relevant API

  • AnalysisOverlay
  • LocationDistanceMeasurement
  • LocationDistanceMeasurement.MeasurementChanged

Additional information

The LocationDistanceMeasurement analysis only performs planar distance calculations. This may not be appropriate for large distances where the Earth's curvature must be considered.

Tags

3D, analysis, distance, measure

Sample Code

DistanceMeasurement.xamlDistanceMeasurement.xamlDistanceMeasurement.xaml.cs
Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<UserControl x:Class="ArcGISRuntime.WinUI.Samples.DistanceMeasurement.DistanceMeasurement"
             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">
    <UserControl.Resources>
        <Style TargetType="TextBlock">
            <Setter Property="Margin" Value="0,5,0,5" />
            <Setter Property="VerticalAlignment" Value="Center" />
        </Style>
    </UserControl.Resources>
    <Grid>
        <esriUI:SceneView x:Name="MySceneView" />
        <Border Style="{StaticResource BorderStyle}">
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="*" />
                    <ColumnDefinition Width="*" />
                </Grid.ColumnDefinitions>
                <!--  Labels  -->
                <TextBlock x:Name="HelpTextBlock"
                           Grid.Row="0"
                           Grid.Column="0"
                           Grid.ColumnSpan="2"
                           FontWeight="SemiBold"
                           Text="Tap 'New measurement' to start."
                           TextWrapping="WrapWholeWords" />
                <TextBlock Grid.Row="1"
                           Grid.Column="0"
                           Text="Direct" />
                <TextBlock Grid.Row="2"
                           Grid.Column="0"
                           Text="Horizontal" />
                <TextBlock Grid.Row="3"
                           Grid.Column="0"
                           Text="Vertical" />

                <!--  Controls  -->
                <TextBlock x:Name="DirectMeasureTextBlock"
                           Grid.Row="1"
                           Grid.Column="1" />
                <TextBlock x:Name="HorizontalMeasureTextBlock"
                           Grid.Row="2"
                           Grid.Column="1" />
                <TextBlock x:Name="VerticalMeasureTextBlock"
                           Grid.Row="3"
                           Grid.Column="1" />
                <ComboBox x:Name="UnitSystemCombo"
                          Grid.Row="4"
                          Grid.Column="0"
                          Grid.ColumnSpan="2"
                          Margin="0,5,0,5"
                          HorizontalAlignment="Stretch" />
                <Button x:Name="NewMeasureButton"
                        Grid.Row="5"
                        Grid.Column="0"
                        Grid.ColumnSpan="2"
                        Margin="0,5,0,0"
                        HorizontalAlignment="Stretch"
                        Click="NewMeasureButton_OnClick"
                        Content="New measurement"
                        IsEnabled="False" />
            </Grid>
        </Border>
    </Grid>
</UserControl>

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