Customize unit lists in the Measurement Widget v4.16

1853
4
Jump to solution
09-28-2020 01:27 PM
NilsBabel1
Occasional Contributor

How do you customize the list of units in the Measurement Widget?  When I create the measurement widget (Measurement | ArcGIS API for JavaScript 4.16 ) it gives me access to the distance and area measurement widget tools.  While I can specify the arealUnit and linearUnit that should be used as the default for the tool I can't customize the list of units displayed.  If I were to create just an AreaMeasurement2D widget or LinearMeasurement2D widget they both have unitOptions property that let's me customize the list.  However, when I create just the Measurement widget it doesn't have a unitOptions, or something similar, property.  So how do I customize the list of units or is that not possible when using the Measurement widget?

0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Emeritus

Nils,

  OK, you seem to be unfamiliar with the 4.x APIs way of watching properties. Just use watchUtils to watch the activeWidget using the whenDefined method.

View solution in original post

4 Replies
RobertScheitlin__GISP
MVP Emeritus

Nils,

  The Measure widgets activeWidget property gives you the AreaMeasurement2D or LinearMeasurement2D depending on which option was chosen by the user.

0 Kudos
NilsBabel1
Occasional Contributor

Thanks Robert, I have seen that property.  But I can't seem to figure out how to work with it.  It doesn't actually tell you the active widget until a user starts clicking on the map to measure.  There are no events on the measurement widget and I'm not sure how to set a listener on the activeWidget property.  The only thing I can think of is to use the 'click' event to check the activeWidget and then change the unitOptions.  But that seems a little heavy handed every time a user clicks on the map.  Is there an easy way to listen for changes to the activeWidget?

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Nils,

  OK, you seem to be unfamiliar with the 4.x APIs way of watching properties. Just use watchUtils to watch the activeWidget using the whenDefined method.

NilsBabel1
Occasional Contributor

Thanks Robert, yes I'm coming from the 3.x API and haven't used watchUtils very much.  That does the trick.  Thanks very much!

0 Kudos