Select to view content in your preferred language

How to reach 'measure-start', 'measure-end' events?

1257
2
05-10-2021 05:33 AM
nidaaktan
Emerging Contributor

Hi,

I'm trying to find the 'measure-start', 'measure-end' events that the new measurement widgets can have.

For example;

measurement.on('measure-start', function (event) {
console.log(event);
});

But It doesn't work that way.

 

0 Kudos
2 Replies
KenBuja
MVP Esteemed Contributor

The 4.x Measure widget doesn't have events. Take a look at this post:

https://community.esri.com/t5/arcgis-api-for-javascript/possible-events-for-new-measurement-widgets-...

EirikH
by
Regular Contributor

How would you then read out the current measurement distance/area from the tool? My case is that using "distance" we need to display the value somewhere else in the UI.

I was hoping for something along the lines of

 

useEffect(() => {
    const measureTool = new Measurement({ linearUnit: 'metric', areaUnit: 'metric' });
    measureTool.on('measurement-update', (event: { distance: number }) => {
      console.log(event.distance);
    });
    setMeasurement(measureTool);
    
  }, []);
0 Kudos