This sample demonstrates how to present Viewsheds in Slides using the ViewshedLayer.
The app loads a webscene which includes some slides and already existing viewsheds. Next, it creates an additional layer to add a viewshed programmatically:
const viewshedLayer = new ViewshedLayer({
title: "Viewpoint 3",
source: new ViewshedAnalysis()
});
const viewshed = new Viewshed({
observer: new Point({
spatialReference: {
latestWkid: 3857,
wkid: 102100
},
x: -7912158.0615638,
y: 5213199.964671738,
z: 30
}),
});
viewshedLayer.source.viewsheds.add(viewshed);
To edit the viewsheds, the interactive property of the
respective ViewshedLayerView needs to bet set to true
.
The sample uses a switch to toggle the interactivity.
const layerView = await view.whenLayerView(layer);
layerView.interactive = !layerView.interactive;