require(["esri/widgets/Slice/SliceViewModel"], (SliceViewModel) => { /* code goes here */ });
import SliceViewModel from "@arcgis/core/widgets/Slice/SliceViewModel.js";
esri/widgets/Slice/SliceViewModel
Provides the logic for the Slice widget. SliceViewModel provides access to the slice plane and the layers that can be excluded from the slice widget.
Constructors
-
Parameterproperties Objectoptional
See the properties for a list of all the properties that may be passed into the constructor.
Property Overview
Name | Type | Summary | Class |
---|---|---|---|
The slice analysis object being created or modified by the view model. | SliceViewModel | ||
The name of the class. | Accessor | ||
Add layers to this collection to exclude them from the slice. | SliceViewModel | ||
Indicates whether the Ground and layers that are draped on the ground surface are excluded from the slice. | SliceViewModel | ||
The shape used to slice elements in a 3D scene. | SliceViewModel | ||
The view model's state. | SliceViewModel | ||
Enable tilting the slice shape. | SliceViewModel | ||
The view from which the widget will operate. | SliceViewModel |
Property Details
-
analysis
analysis SliceAnalysisautocastreadonly
Since: ArcGIS Maps SDK for JavaScript 4.23SliceViewModel since 4.10, analysis added at 4.23. -
The slice analysis object being created or modified by the view model.
This property can be set during view model construction, to provide an existing analysis to the view model for modification. Properties on the analysis can also be updated once it's assigned to the view model.
If no analysis is provided during view model construction, 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 model const analysis = 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 view view.analyses.add(analysis); // Frame the analysis in the view view.goTo(analysis.extent); // Pass the analysis object as a constructor parameter to modify it using the view model const viewModel = new SliceViewModel({ analysis: analysis, view: view });
-
excludedLayers
excludedLayers Collection<(Layer|BuildingComponentSublayer)>
-
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
shape SlicePlaneautocast
Since: ArcGIS Maps SDK for JavaScript 4.16SliceViewModel since 4.10, shape added at 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 properties const shape = viewModel.shape.clone(); // Set new values for heading and tilt shape.heading = 180; shape.tilt = 45; // Set the new properties on the viewModel's shape viewModel.shape = shape;
-
state
state Stringreadonly
-
The view model's state.
Value Description disabled not ready yet ready ready for slicing slicing currently slicing sliced finished slicing Possible Values:"disabled" |"ready" |"slicing" |"sliced"
- Default Value:disabled
-
tiltEnabled
tiltEnabled Boolean
Since: ArcGIS Maps SDK for JavaScript 4.16SliceViewModel since 4.10, tiltEnabled added at 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
-
view
view SceneView
-
The view from which the widget will operate.
Method Overview
Name | Return Type | Summary | Class |
---|---|---|---|
Adds one or more handles which are to be tied to the lifecycle of the object. | Accessor | ||
Clears the shape of the slice, effectively removing it from the view. | SliceViewModel | ||
Returns true if a named group of handles exist. | Accessor | ||
Removes a group of handles owned by the object. | Accessor | ||
Starts the interactive creation of a new slice, clearing the previous shape. | SliceViewModel |
Method Details
-
Inherited from Accessor
Since: ArcGIS Maps SDK for JavaScript 4.25Accessor since 4.0, addHandles added at 4.25. -
Adds one or more handles which are to be tied to the lifecycle of the object. The handles will be removed when the object is destroyed.
// Manually manage handles const handle = reactiveUtils.when( () => !view.updating, () => { wkidSelect.disabled = false; }, { once: true } ); this.addHandles(handle); // Destroy the object this.destroy();
ParametershandleOrHandles WatchHandle|WatchHandle[]Handles marked for removal once the object is destroyed.
groupKey *optionalKey identifying the group to which the handles should be added. All the handles in the group can later be removed with Accessor.removeHandles(). If no key is provided the handles are added to a default group.
-
Since: ArcGIS Maps SDK for JavaScript 4.16SliceViewModel since 4.10, clear added at 4.16. -
Clears the shape of the slice, effectively removing it from the view. Other properties like excludedLayers and excludeGroundSurface are not modified.
-
hasHandles
InheritedMethodhasHandles(groupKey){Boolean}
Inherited from AccessorSince: ArcGIS Maps SDK for JavaScript 4.25Accessor since 4.0, hasHandles added at 4.25. -
Returns true if a named group of handles exist.
ParametergroupKey *optionalA group key.
ReturnsType Description Boolean Returns true
if a named group of handles exist.Example// Remove a named group of handles if they exist. if (obj.hasHandles("watch-view-updates")) { obj.removeHandles("watch-view-updates"); }
-
Inherited from Accessor
Since: ArcGIS Maps SDK for JavaScript 4.25Accessor since 4.0, removeHandles added at 4.25. -
Removes a group of handles owned by the object.
ParametergroupKey *optionalA group key or an array or collection of group keys to remove.
Exampleobj.removeHandles(); // removes handles from default group obj.removeHandles("handle-group"); obj.removeHandles("other-handle-group");
-
Since: ArcGIS Maps SDK for JavaScript 4.16SliceViewModel since 4.10, start added at 4.16. -
Starts the interactive creation of a new slice, clearing the previous shape.