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?
Solved! Go to Solution.
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.
Nils,
The Measure widgets activeWidget property gives you the AreaMeasurement2D or LinearMeasurement2D depending on which option was chosen by the user.
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?
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.
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!