1

I am using ArcGIS's JS API for Measurement tool to measure and display Area, Distance, and Location points, but I cannot seem to be able to change the units programmatically. There's a method for GetUnits(), but no corresponding SetUnits(), and modifying the values in the DOM doesn't work because the dropdown that their widget creates isn't a dropdown at all, its a div and some span elements modified to look like a dropdown.

I just started a new job with a mapping company that uses this, and I'm rather new to GIS, so I apologize if there is an obvious solution that I'm not aware of.

0

I've never actually needed to do this (in fact I'm wondering why you ever would need to because the user can change the units in the widget) so my answer will be brief. First thing to do is visit the api page for the Measurement widget.

https://developers.arcgis.com/javascript/jsapi/measurement-amd.html

You can look at the "Constructor Details" and see params/properties listed including Units so you can define your own "params" object and pass that in. This is really only for setting the defaults and I believe beyond that, you really won't be able to do much unless you completely rebuild the widget.

Next take a look at the specifics of the units parameter (here is another link).

https://developers.arcgis.com/javascript/jsapi/units-amd.html

That is about the best I can do for you.

  • 1
    Hi, thank you for the help. The reason I am needing to do this is that we are re-skinning the measurement widget to fall more in line with the theming of our website, and we are also expanding on the "history" by listing the previously created measurements. That way, a user could click on a previously created measurement and have it display on the map again. – FullMetalEngineer Sep 18 '15 at 14:58
0

I was only able to get the functionality I needed by re-instantiating a new measurement widget each time that I wanted to switch units.

There exists no method for changing the units of the measurement widget while running.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.