The ArcGIS Server JavaScript API has a Measurement widget, which reports the area or length of a shape drawn on the map.

The default metric labels use the American spelling of "Sq Kilometers" and "Kilometers", etc.

enter image description here

var measurement = new Measurement({
        map: map,
        defaultAreaUnit: units.SQUARE_KILOMETERS,
        defaultLengthUnit: units.KILOMETERS
}, dom.byId("measurementDiv"));


Is it possible to change the default text "Square Kilometers" shown by default to a custom text (like "km2")?

The Measurement widget doesn't seem to have any customisation options which would accomplish this.

  • What version of the ArcGIS API for JavaScript are you using?
    – PolyGeo
    Commented Jun 5, 2017 at 21:21
  • It will most likely be 3.x or 4.x. 10.2 may be your Server version.
    – PolyGeo
    Commented Jun 6, 2017 at 19:48
  • @PolyGeo yeah, you're right. Api is v 3.13 Commented Jun 6, 2017 at 19:54
  • @StephenLead i think the same.I have no idea about building my own measuring widget. Could you suggest some reading materials? thanks. Commented Jun 7, 2017 at 19:00

1 Answer 1


You can change this string, like many other strings in the ArcGIS API for JavaScript, by taking advantage/overwriting the localizable strings.

This is documented at the bottom of the localization doc - https://developers.arcgis.com/javascript/3/jshelp/localization.html

require([..., "dojo/i18n!esri/nls/jsapi", ... ],
  function(..., bundle, ...) {
    bundle.widgets.measurement.NLS_area_sq_kilometers = "km<sup>2</sup>";
    // or bundle.widgets.measurement.NLS_area_sq_kilometers = "km2";
  • Well, i would have preferred to have a nice "setText" method or something in that vein. But your solution does it. Thank you very much. Commented Jun 8, 2017 at 21:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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