Disable Draw Toolbar when using Measurement widget

690
6
09-18-2017 12:50 PM
StevenBills1
New Contributor

I have a map using the 3.21 JavaScript API that contains a Draw Toolbar and a Measurement widget. I would like to disable the Draw Toolbar when the Measurement widget is used so the user isn't drawing while measuring. I tried attaching to the tool-change event of the Measurement widget and deactivating the Draw Toolbar from there, but that's causing issues with the Measurement widget where the last segments of the area or distance measurements aren't added to the total. Is there a good way of deactivating the Draw Toolbar when using the Measurement widget?

0 Kudos
6 Replies
RobertScheitlin__GISP
MVP Emeritus

Steve,

   I am not sure what you have tried but this is how I would handle it:

aspect.after(measurement, 'setTool', lang.hitch(this, function() {
  if (measurement.activeTool) {
    //deactive the draw tool
  } else {
    //activate the draw tool
  }
}));
0 Kudos
StevenBills1
New Contributor

Robert,

Thanks. I wasn't familiar with aspect and it seems super useful.

I gave this a try and I'm still having the issue with the measure tool not including the last segment of the line or area in the measurement after deactivating the draw toolbar.

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Steven,

   Can you put together a small sample app that demonstrates you issue. That way I can debug some actual code for you.

0 Kudos
StevenBills1
New Contributor

Robert,

I made a sample on CodePen here:

https://codepen.io/anon/pen/MEyyyd?editors=1000 

Thanks.

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Steven,

   This seems like a bug that you need to report to esri tech support.

0 Kudos
StevenBills1
New Contributor

Robert,

Thanks for the help. I'll get a support case going with esri.

0 Kudos