Line Of Sight

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

The Line Of Sight component is a 3D analysis tool that allows you to perform line of sight visibility analysis in a Scene. Visibility between a given observer and multiple target points is calculated against the currently displayed content in the view, including the ground, integrated meshes, and 3D objects such as buildings or trees.

line-of-sight

The analysis results are displayed as colored lines, where areas visible to the observer are shown green and occluded parts are marked in red. Also, the color of the target points indicates their visibility. When the line of sight cannot be calculated, it will be displayed with a gray color. This may happen if either the target or the observer is not in the view.

When creating a new line of sight analysis, the first click in the Scene creates the observer and subsequent clicks place the targets. Both the observer and target points can be moved by dragging. Additionally, the target points can be removed with a right click.

Known limitation

Line Of Sight is only supported in a 3D Scene component.

See also

Demo

Properties

PropertyAttributeType
auto-destroy-disabled
boolean
icon
string
label
string
Record<string, unknown>
position
"bottom-leading" | "bottom-left" | "bottom-right" | "bottom-trailing" | "manual" | "top-leading" | "top-left" | "top-right" | "top-trailing"
reference-element
state
readonly
state
"created" | "creating" | "disabled" | "ready"

analysis

Property

The LineOfSightAnalysis created or modified by the component.

When connecting the Line Of Sight 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
25
26
27
28
29
//Create the analysis.
const lineOfSightAnalysis = new LineOfSightAnalysis({
  observer: new LineOfSightAnalysisObserver({
        position: new Point({
        spatialReference: { latestWkid: 3857, wkid: 102100 },
        x: -13624828.3377593,
        y: 4550305.319405007,
        z: 105.55410975124687
        }),
  }),
  targets: [ new LineOfSightAnalysisTarget({
        position: new Point({
        spatialReference: { latestWkid: 3857, wkid: 102100 },
        x: -13624944.17687458,
        y: 4550420.577689567,
        z: 0
        }),
  })
]
});
// Get the Scene and Line Of Sight component and wait until they are ready.
const viewElement = document.querySelector("arcgis-scene");
await viewElement.viewOnReady();
const lineOfSight = document.querySelector("arcgis-line-of-sight");
await lineOfSight.componentOnReady();
// Add the analysis to the Scene component.
viewElement.analyses.add(lineOfSightAnalysis);
// Connect the analysis to the component:
lineOfSight.analysis = lineOfSightAnalysis;

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
"line-of-sight"

label

Property
label: string

The component's default label.

Attribute
label

messageOverrides

Property
messageOverrides: Record<string, unknown>

Replace localized message strings with your own strings.

Note: Individual message keys may change between releases.

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: "created" | "creating" | "disabled" | "ready"

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

  • disabled - not ready yet
  • ready - ready for analysis
  • creating - observer/target points are being placed
  • created - finished analysis
Attribute
state

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>
continue(): Promise<void>
destroy(): Promise<void>
start(): Promise<void>
stop(): Promise<void>

clear

Method
clear(): Promise<void>

Clear the current analysis results. After calling this method, the user can set a new observer and targets.

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 arcgisLineOfSight = document.querySelector("arcgis-line-of-sight");
document.body.append(arcgisLineOfSight);
await arcgisLineOfSight.componentOnReady();
console.log("arcgis-line-of-sight is ready to go!");
Returns
Promise<void>

continue

Method
continue(): Promise<void>

After stop() was called, this method allows to continue the line of sight analysis and add more targets.

Returns
Promise<void>

destroy

Method
destroy(): Promise<void>

Permanently destroy the component.

Returns
Promise<void>

start

Method
start(): Promise<void>

Start a new line of sight analysis.

Returns
Promise<void>

stop

Method
stop(): Promise<void>

Stop the current placing of line of sight analysis. Any lines added this far are kept in the view. Users can still interact with existing targets and the observer, but they cannot place new target points.

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.