DirectLineMeasurement3D - Events

584
1
Jump to solution
05-22-2018 08:54 PM
MichalGasparovic
New Contributor III

Hi, 

I don't seem to be able to find any usable events for this widget, for example, are there any events like:

-  OnMeasureStart

-  OnMeasureEnd  

(or similar)?

Are there any methods that would allow me to partially control the widget? I know there is "clearMeasurement()", but what I'm after is:

 - startMeasurement (something like letting the widget know that now it's time to attach the view click listeners)

 - stopMeasurement (cancelling if it's started, detach any listeners) ?

Is there a way how can I force this widget to cancel and stop measuring without actually having to destroy the widget? ClearMeasurement() method will reset the widget, but it still expects the input.

No offense, but if there is nothing like that then the widget is useless for the developers who wants to reuse the widget but incorporate few more extra logic on top of it, or just simply make it to listen to the UI of their own application. (I'd like to have my own custom tool instructions for example) and I'd love to also know when the widget actually stopped drawing etc.

 

Thank you for all your help. 

1 Solution

Accepted Solutions
RalucaNicola1
Esri Contributor

Hi Michal,

The measurement widgets in 3D are still work in progress. However to have more control of the interaction I would advise to use the ViewModel of the widget: DirectLineMeasurement3DViewModel | API Reference | ArcGIS API for JavaScript 4.7 

There you can watch for changes of the `state` attribute to figure out when the measurement started. The pattern in the API is that all properties are watch-able, so we don't really use event listeners so much. You can read about it in this guide topic: Working with properties | ArcGIS API for JavaScript 4.7 

Indeed, for now the only public way to stop measuring is to destroy it. We are working on a public API that would work for all the widgets that have an enabled/disabled state, but we didn't implement it yet.

View solution in original post

1 Reply
RalucaNicola1
Esri Contributor

Hi Michal,

The measurement widgets in 3D are still work in progress. However to have more control of the interaction I would advise to use the ViewModel of the widget: DirectLineMeasurement3DViewModel | API Reference | ArcGIS API for JavaScript 4.7 

There you can watch for changes of the `state` attribute to figure out when the measurement started. The pattern in the API is that all properties are watch-able, so we don't really use event listeners so much. You can read about it in this guide topic: Working with properties | ArcGIS API for JavaScript 4.7 

Indeed, for now the only public way to stop measuring is to destroy it. We are working on a public API that would work for all the widgets that have an enabled/disabled state, but we didn't implement it yet.