This sample demonstrates how you can instantiate an analysis object for the following types:
- DirectLineMeasurementAnalysis Object
- AreaMeasurementAnalysis Object
- SliceAnalysis Object
- LineOfSightAnalysis Object
- ViewshedAnalysis Object
These objects can be added to SceneView.analyses, a collection of client side analyses. This allows for measuring, slicing and performing visibility analyses programmatically without the use of widgets. Further, these objects can be passed to the constructor of widgets and view models in order to set their initial state.
// Example Slice Analysis Object
const shape = new SlicePlane({
position: {
spatialReference: { wkid: 102100 },
x: -8238840,
y: 4971700,
z: 21
},
tilt: 0,
width: 70,
height: 70,
heading: 280
});
const sliceAnalysis = new SliceAnalysis({
title: "sliceAnalysis",
shape: shape
});
// Add slice analysis object to slice widget
const widget = new Slice({ view: view, analysis: sliceAnalysis });
view.ui.add(widget, "bottom-right");
For using AreaMeasurementAnalysis Object see also the sample Area measurement analysis object.
The sample also shows how to create a custom UI element to interactively add and edit the viewshed analysis.