Direct Line Measurement 3D

ESM:
Use dark colors for code blocksCopy
1
import "@arcgis/map-components/components/arcgis-direct-line-measurement-3d";
CDN:
No specific import is needed for this component.

The Direct Line Measurement 3D component can be added to a Scene component to calculate and display vertical, horizontal, and direct distances between two points.

measurement-line-3d

How distances are computed depends on the scene's spatial reference.

In geographic coordinate systems (GCS) and in Web Mercator:

  • Direct distance is computed in a Euclidean manner, in an ECEF coordinate system (or equivalent on other planets);
  • Horizontal distance is computed geodetically, taking into consideration the curvature of the planet;
  • Vertical distance is computed as an elevation difference.

In projected coordinate systems (PCS), apart from Web Mercator, all three distances (direct, horizontal, and vertical) are computed in a Euclidean manner (in their respective PCS).

Direct Line Measurement 3D component visualizes and labels the direct, horizontal, and vertical distances and displays the same values in the UI panel. When the distance between the points is greater than 100 kilometers, the measurement visualization is simplified, and only the horizontal and vertical distances are calculated. The direct distance option becomes unavailable.

measurement-line-3d

When the component is active, a horizontal "laser" line is drawn which indicates the height at the current mouse position. This line can help in analyzing the heights of objects relative to each other and the terrain. A second laser line shows the intersection of the scene with the vertical plane that passes through the checkered line.

Things to consider

See also

Demo

Properties

PropertyAttributeType
auto-destroy-disabled
boolean
icon
string
label
string
position
"bottom-leading" | "bottom-left" | "bottom-right" | "bottom-trailing" | "manual" | "top-leading" | "top-left" | "top-right" | "top-trailing"
reference-element
state
readonly
state
"disabled" | "measured" | "measuring" | "ready"
unit
"centimeters" | "decimeters" | "feet" | "imperial" | "inches" | "kilometers" | "meters" | "metric" | "miles" | "millimeters" | "nautical-miles" | "us-feet" | "yards"
Array<"imperial" | "metric" | "millimeters" | "centimeters" | "decimeters" | "meters" | "kilometers" | "inches" | "feet" | "yards" | "miles" | "nautical-miles" | "us-feet">

analysis

Property

The DirectLineMeasurementAnalysis created or modified by the component.

When connecting the Direct Line Measurement 3D component to the Scene component, it automatically creates an empty analysis and adds it to the Scene's analyses collection. Whenever the component is destroyed, the analysis is automatically removed from the collection.

Alternatively, a programmatically created analysis can be provided to the component. Then, the application itself needs to add it to and later remove it from the Scene's analyses collection.

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
// Create the analysis.
const directLineAnalysis = new DirectLineMeasurementAnalysis({
   startPoint: new Point({
     spatialReference: { latestWkid: 3857, wkid: 102100 },
     x: -13624995.61798748,
     y: 4550334.030096778,
     z: 63.378210234455764
   }),
   endPoint: new Point({
     spatialReference: { latestWkid: 3857, wkid: 102100 },
     x: -13624921.53589075,
     y: 4550407.42357004,
     z: 63.3783810287714
   }),
});
// Get the Scene and measurement component and wait until they are ready.
const viewElement = document.querySelector("arcgis-scene");
await viewElement.viewOnReady();
const directLineMeasurement3d = document.querySelector("arcgis-direct-line-measurement-3d");
await directLineMeasurement3d.componentOnReady();
// Add the analysis to the Scene component.
viewElement.analyses.add(directLineAnalysis);
// Connect the analysis to the measurement component:
directLineMeasurement3d.analysis = directLineAnalysis;

autoDestroyDisabled

Property
autoDestroyDisabled: boolean

If true, the component will not be destroyed automatically when it is disconnected from the document. This is useful when you want to move the component to a different place on the page, or temporarily hide it. If this is set, make sure to call the destroy method when you are done to prevent memory leaks.

Attribute
auto-destroy-disabled
Default value
false

icon

reflected

Attribute changes are reflected on the DOM.

Property
icon: string

Icon which represents the component. Typically used when the component is controlled by another component (e.g. by the Expand component).

See also
Attribute
icon
Default value
"measure-line"

label

Property
label: string

The component's default label.

Attribute
label

position

Property
position: "bottom-leading" | "bottom-left" | "bottom-right" | "bottom-trailing" | "manual" | "top-leading" | "top-left" | "top-right" | "top-trailing"
Attribute
position
Default value
"bottom-left"

referenceElement

Property

By assigning the id attribute of the Map or Scene component to this property, you can position a child component anywhere in the DOM while still maintaining a connection to the Map or Scene.

See also
Attribute
reference-element

state

readonlyreflected

Attribute changes are reflected on the DOM.

Property
state: "disabled" | "measured" | "measuring" | "ready"

The component's state. The values mean the following:

  • disabled - not ready yet
  • ready - ready for measuring
  • measuring - currently measuring
  • measured - measuring has finished
Attribute
state

unit

Property
unit: "centimeters" | "decimeters" | "feet" | "imperial" | "inches" | "kilometers" | "meters" | "metric" | "miles" | "millimeters" | "nautical-miles" | "us-feet" | "yards"

Unit system (imperial, metric) or specific unit used for displaying the distance values. Possible values are listed in unitOptions.

Attribute
unit

unitOptions

Property
unitOptions: Array<"imperial" | "metric" | "millimeters" | "centimeters" | "decimeters" | "meters" | "kilometers" | "inches" | "feet" | "yards" | "miles" | "nautical-miles" | "us-feet">

List of available units and unit systems (imperial, metric) that are shown in the component's dropdown. By default, the following units are included: metric, imperial, inches, feet, us-feet, yards, miles, nautical-miles, meters, kilometers. Possible unit values can only be a subset of this list.

Slots

No slots to display.

Events

EventType
CustomEvent<{ name: "state" | "analysis"; }>

arcgisPropertyChange

Event
arcgisPropertyChange: CustomEvent<{ name: "state" | "analysis"; }>

Emitted when the value of a property is changed. Use this to listen to changes to properties.

bubbles

Events triggered on this element will be propagated to their outermost elements.

composed

The event is composable and will propagate across the shadow DOM into the standard DOM.

cancelable

The event's default behavior can be canceled, allowing for custom behavior to be implemented instead.

arcgisReady

Event
arcgisReady: CustomEvent<void>

Emitted when the component associated with a map or scene view is is ready to be interacted with.

bubbles

Events triggered on this element will be propagated to their outermost elements.

composed

The event is composable and will propagate across the shadow DOM into the standard DOM.

cancelable

The event's default behavior can be canceled, allowing for custom behavior to be implemented instead.

Methods

MethodSignature
clear(): Promise<void>
componentOnReady(): Promise<void>
destroy(): Promise<void>
start(): Promise<void>

clear

Method
clear(): Promise<void>

Clears the current measurement.

Returns
Promise<void>

componentOnReady

Method
componentOnReady(): Promise<void>

Create a promise that resolves once component is fully loaded.

Example
Use dark colors for code blocksCopy
1
2
3
4
const arcgisDirectLineMeasurement3d = document.querySelector("arcgis-direct-line-measurement-3d");
document.body.append(arcgisDirectLineMeasurement3d);
await arcgisDirectLineMeasurement3d.componentOnReady();
console.log("arcgis-direct-line-measurement-3d is ready to go!");
Returns
Promise<void>

destroy

Method
destroy(): Promise<void>

Permanently destroy the component.

Returns
Promise<void>

start

Method
start(): Promise<void>

Starts a new measurement.

Returns
Promise<void>

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