Select to view content in your preferred language

ArcGIS JS API AreaMeasurement3D Result

443
2
Jump to solution
01-24-2023 04:56 AM
Wade
by
Occasional Contributor

What events can be used to obtain the results measured by these tools, such as extent or area?

0 Kudos
1 Solution

Accepted Solutions
Wade
by
Occasional Contributor

Thanks, for this interesting use case using reactiveUtils .

View solution in original post

0 Kudos
2 Replies
ReneRubalcava
Honored Contributor

This is a fun use case for using reactiveUtils.

The AreaMeasurement3D has an analysis object with the geometry being drawn that you can watch for changes.

It also has a measurement object on the viewModel. So you can watch the area or the perimeterLength to get those values when using it. This is the displayed text for these, so not raw numbers, but looks like the results of the geometryEngine functions used on the analysis object.

 

watch(
    // watch for the analysis geometry to update
    () => activeWidget.analysis?.geometry,
    () => console.log("analysis", activeWidget.analysis)
);
when(
    // wait for the area text to be available
    () => activeWidget.viewModel.measurement?.area.state === "available",
    () => console.log(activeWidget.viewModel.measurement)
);
when(
    // wait for the perimeter text to be available
    () => activeWidget.viewModel.measurement?.perimeterLength.state === "available"
    () => console.log(activeWidget.viewModel.measurement)
);

 

demo: https://codepen.io/odoe/pen/abjYLzy?editors=1000

Wade
by
Occasional Contributor

Thanks, for this interesting use case using reactiveUtils .

0 Kudos