A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://developers.arcgis.com/javascript/latest/sample-code/analysis-objects/ below:

Analysis objects | Sample Code | ArcGIS Maps SDK for JavaScript 4.33

This sample demonstrates how to create client side analysis in a Scene component.

Analyses allow creating custom measuring or visibility analysis workflows and accompanying UI without the use of respective components. The sample covers the following types:

These objects can be created programmatically and added to the Scene component's analyses collection.

The following snippets use the SliceAnalysis as an example:

Use dark colors for code blocks Copy

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
const analysis = new SliceAnalysis({
  shape: new SlicePlane({
    position: new Point({
      x: -8238840,
      y: 4971700,
      z: 21,
      spatialReference: SpatialReference.WebMercator,
    }),
    tilt: 0,
    width: 70,
    height: 100,
    heading: 278,
  }),
});

viewElement.analyses.add(analysis);

By accessing the respective analysis view, one can programmatically start interactive analysis operations. For example, an already existing analysis geometry can be edited by enabling the interactive property.

Use dark colors for code blocks Copy

1
2
const analysisView = await viewElement.whenAnalysisView(analysis);
analysisView.interactive = true;

With the place() method it is possible to start adding a new analysis. In this sample, the placeContinuous() function shows how to call the place() method again after the previous analysis was placed. This is continued until either Escape is pressed or "Done" button clicked.

Use dark colors for code blocks Copy

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
let abortController;
async function placeContinuous() {
  // Stop any previous placing and create a new controller.
  abortController?.abort();
  abortController = new AbortController();
  // Get a reference to the signal for the new placement operation.
  const { signal } = abortController;
  try {
    // After one analysis is placed, call the place() method again.
    // This is done until the placing is aborted.
    while (!signal.aborted) {
      // Pass the signal as an argument to the interactive place method.
      await activeTool.analysisView.place({
        signal,
      });
    }
  } catch (error) {
    // Avoid logging the abort errors.
    if (!promiseUtils.isAbortError(error)) {
      throw error;
    }
  } finally {
    // Remove the controller if this was the last started placement.
    if (abortController?.signal === signal) {
      abortController = null;
    }
  }
}

Clicking the "Done" button calls abort() and stops the placing programmatically.

Use dark colors for code blocks Copy

1
2
3
doneButton.addEventListener("click", () => {
  abortController.abort();
});

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4