Customize unit lists in the Measurement Widget v4.16

136
4
Jump to solution
09-28-2020 01:27 PM
Highlighted
New Contributor III

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?

Reply
0 Kudos
1 Solution

Accepted Solutions
Highlighted
MVP Esteemed Contributor

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
Highlighted
MVP Esteemed Contributor

Nils,

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

Reply
0 Kudos
Highlighted
New Contributor III

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?

Reply
0 Kudos
Highlighted
MVP Esteemed Contributor

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

Highlighted
New Contributor III

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!

Reply
0 Kudos