import SliceViewModel from "@arcgis/core/widgets/Slice/SliceViewModel.js";const SliceViewModel = await $arcgis.import("@arcgis/core/widgets/Slice/SliceViewModel.js");- Inheritance:
- SliceViewModel→
Accessor
- Since
- ArcGIS Maps SDK for JavaScript 4.10
Provides the logic for the Slice widget and component. SliceViewModel provides access to the slice plane and the layers that can be excluded from the slice widget.
- See also
Slice widget - Deprecated since 4.33. Use the Slice component instead.
Constructors
Constructor
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| properties | | |
Properties
| Property | Type | Class |
|---|---|---|
| | ||
declaredClass readonly inherited | ||
| | ||
| | ||
SlicePlane | null | undefined | | |
state readonly | "disabled" | "ready" | "slicing" | "sliced" | |
| | ||
| |
analysis
- Type
- SliceAnalysis
- Since
- ArcGIS Maps SDK for JavaScript 4.23
The slice analysis object being created or modified by the view model.
If no analysis is provided, the view model automatically creates its own analysis and adds it to the view. In this case, the analysis will also be automatically removed from the view when the view model is destroyed.
Example
// Construct a slice analysis object outside of the view modelconst sliceAnalysis = new SliceAnalysis({ shape: { type: "plane", // autocasts as new SlicePlane() position: { type: "point", x: -0.1, y: 51.5 }, width: 50, height: 50, tilt: 45 }, tiltEnabled: true});
// Ensure that the analysis is added to the viewview.analyses.add(sliceAnalysis);
// Frame the analysis in the viewview.goTo(sliceAnalysis.extent);
// Pass the analysis object as a constructor parameter to modify it using the view modelconst sliceViewModel = new SliceViewModel({ analysis: sliceAnalysis, view: view}); excludedLayers
- 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
shape
- Type
- SlicePlane | null | undefined
- Since
- ArcGIS Maps SDK for JavaScript 4.16
The shape used to slice elements in a 3D scene. Currently the only supported shape is a plane.
Example
// Clone the shape to modify its propertiesconst shape = sliceViewModel.shape.clone();
// Set new values for heading and tiltshape.heading = 180;shape.tilt = 45;
// Set the new properties on the slice view model's shapesliceViewModel.shape = shape; tiltEnabled
- Type
- boolean
- Since
- ArcGIS Maps SDK for JavaScript 4.16
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.
- Default value
- false
Methods
clear
- Signature
-
clear (): void
- Since
- ArcGIS Maps SDK for JavaScript 4.16
Clears the shape of the slice, effectively removing it from the view. Other properties like excludedLayers and excludeGroundSurface are not modified.
- Returns
- void