Skip to content
ESM
import "@arcgis/map-components/components/arcgis-slice";
Inheritance:
ArcgisSlicePublicLitElement

The Slice component is a 3D analysis tool that can be used to reveal occluded content in a arcgis-scene. It applies slice analysis to any layer type, making it possible to see inside buildings or to explore geological surfaces.

slice

The slicing shape is always a plane. By default, the plane is either horizontal or vertical. To allow a tilt angle for the plane, set tiltEnabled to true. The slice hides any content in front of the surface. The handles on the sides of the plane can be used to adjust the size, heading, tilt, and position of the slice plane. The SlicePlane can be set or retrieved using the shape property.

Once the slice plane is applied, layers can be excluded from the slicing. For example, by excluding the sublayers which include columns and floor slabs, the inner structure of a building can investigated.

slice-exclude

Holding the Shift key while placing a new slice applies it vertically.

Known limitation

Slice is only supported in a 3D arcgis-scene component.

See also

Demo

Properties

PropertyAttributeType
auto-destroy-disabled
exclude-ground-surface
heading-level
hide-start-button
hide-visualization
icon
reflected
icon
Icon["icon"] | undefined
label
reference-element
state
readonly
"disabled" | "ready" | "excludingLayer" | "sliced" | "slicing"
tilt-enabled

analysis

Property
Type
SliceAnalysis

The SliceAnalysis created or modified by the component.

When connecting the Slice component to the arcgis-scene component, it automatically creates an empty analysis and adds it to the Scene's arcgis-scene.analyses collection. You can then wait for the SliceAnalysisView3D to be created before interacting with the slice or reading the current slice parameters.

// Get the Scene component and the Slice component, and wait until both are ready.
const viewElement = document.querySelector("arcgis-scene");
await viewElement.viewOnReady();
const sliceElement = document.querySelector("arcgis-slice");
await sliceElement.componentOnReady();
// Get the SliceAnalysis created by the Slice component.
const analysis = sliceElement.analysis;
// Get the SliceAnalysisView3D and watch for changes.
const analysisView = await viewElement.whenAnalysisView(analysis);
const handle = reactiveUtils.watch(
() => analysis.shape,
() => {
console.log("Slice active:", analysisView.active);
console.log("Slice interactive:", analysisView.interactive);
console.log("Slice shape:", analysis.shape);
},
);

Whenever the component is destroyed, the analysis is automatically removed from the collection.

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

// Create the SliceAnalysis.
const sliceAnalysis = new SliceAnalysis({
shape: new SlicePlane({
position: new Point({
spatialReference: { latestWkid: 3857, wkid: 102100 },
x: -13624925.727820931,
y: 4550341.695170021,
z: 56
}),
tilt: 270,
width: 310,
height: 190,
heading: 45
})
});
// Get the Scene component and the Slice component, and wait until both are ready.
const viewElement = document.querySelector("arcgis-scene");
await viewElement.viewOnReady();
const sliceElement = document.querySelector("arcgis-slice");
await sliceElement.componentOnReady();
// Add the analysis to the analyses collection of the Scene component.
viewElement.analyses.add(sliceAnalysis);
// Connect the analysis to the slice component:
sliceElement.analysis = sliceAnalysis;

autoDestroyDisabled

Property
Type
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

excludedLayers

Property
Type
Collection<SliceableLayer>

Add layers to this collection to exclude them from the slice. Layers that are draped on the ground surface are not affected by this property

excludeGroundSurface

Property
Type
boolean

Indicates whether the Ground and layers that are draped on the ground surface are excluded from the slice.

Attribute
exclude-ground-surface
Default value
false

headingLevel

Property
Type
HeadingLevel

Indicates the heading level to use for the "Excluded layers" heading.

Attribute
heading-level
Default value
3

hideStartButton

Property
Type
boolean
Since
ArcGIS Maps SDK for JavaScript 5.0

If true, the button that starts a new slice will be hidden.

Attribute
hide-start-button
Default value
false

hideVisualization

Property
Type
boolean
Since
ArcGIS Maps SDK for JavaScript 5.0

Indicates whether the component's visualization is hidden in the view.

Attribute
hide-visualization
Default value
false

icon

reflected Property
Type
Icon["icon"] | undefined

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
"slice"

label

Property
Type
string | undefined

The component's default label.

Attribute
label

messageOverrides

Property
Type
Record<string, unknown> | undefined

Replace localized message strings with your own strings.

Note: Individual message keys may change between releases.

referenceElement

Property
Type
ArcgisReferenceElement | string | undefined

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

shape

Property
Type
SlicePlane | null | undefined
Since
ArcGIS Maps SDK for JavaScript 4.28

The shape used to slice elements in a 3D scene. Currently the only supported shape is a plane.

Examples
// Create a slice plane programmatically.
const shape = new SlicePlane({
position: new Point({
spatialReference: { latestWkid: 3857, wkid: 102100 },
x: -13624925.727820931,
y: 4550341.695170021,
z: 56
}),
tilt: 270,
width: 310,
height: 190,
heading: 45
});
// Apply the new shape to the slice component's shape.
slice.shape = shape;
// Clone the shape to modify its properties.
const shape = slice.shape.clone();
// Set new values for heading and tilt.
shape.heading = 180;
shape.tilt = 45;
// Apply the new shape to the slice component's shape.
slice.shape = shape;

state

readonly Property
Type
"disabled" | "ready" | "excludingLayer" | "sliced" | "slicing"

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

  • disabled - not ready yet
  • excludingLayer - currently excluding a layer from the slice
  • ready - ready for slicing
  • slicing - currently slicing
  • sliced - finished slicing and a valid shape is available

tiltEnabled

Property
Type
boolean

Enable tilting the slice shape. If set to true, the slice shape will orient itself as best as possible to the surface under the cursor when first placing the shape. If set to false, the slice shape is restricted to be either horizontal or vertical.

Attribute
tilt-enabled
Default value
false

view

Property
Type
SceneView | undefined

The view associated with the component.

Note: The recommended approach is to fully migrate applications to use map and scene components and avoid using MapView and SceneView directly. However, if you are migrating a large application from widgets to components, you might prefer a more gradual transition. To support this use case, the SDK includes this view property which connects a component to a MapView or SceneView. Ultimately, once migration is complete, the arcgis-slice component will be associated with a map or scene component rather than using the view property.

Methods

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

clear

Method
Signature
clear (): Promise<void>

Clear the shape of the slice, effectively removing it from the view. Other properties like excludedLayers and excludeGroundSurface are not modified. Calling this method changes the state to ready.

Returns
Promise<void>

componentOnReady

inherited Method
Signature
componentOnReady (): Promise<this>
Inherited from: PublicLitElement

Creates a promise that resolves once the component is fully loaded.

Returns
Promise<this>
Example
const arcgisSlice = document.querySelector("arcgis-slice");
document.body.append(arcgisSlice);
await arcgisSlice.componentOnReady();
console.log("arcgis-slice is ready to go!");

destroy

Method
Signature
destroy (): Promise<void>

Permanently destroy the component.

Returns
Promise<void>

start

Method
Signature
start (): Promise<void>

Start the interactive placement of a new slice, clearing the previous shape. Calling this method changes the state to slicing.

Returns
Promise<void>

Events

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

arcgisPropertyChange

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

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

bubbles composed cancelable

arcgisReady

Event
arcgisReady: CustomEvent<void>

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

bubbles composed cancelable