Select to view content in your preferred language

How to remove measures in the Measurement widget ?

896
2
Jump to solution
04-09-2018 12:44 AM
LioritClément
Emerging Contributor

I would like to remove measures that I do not use in the Measurement widget.

0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Emeritus

Liorit,

   In the Widget.js you can add this code:

Line 17 I am setting the default length unit to Kilometers.

Line 28 and 29 I am removing Miles as an option.

      startup: function() {
        if (this.measurement || this._pcDef) {
          return;
        }
        this.inherited(arguments);

        var json = this.config.measurement;
        json.map = this.map;
        if (json.lineSymbol) {
          json.lineSymbol = jsonUtils.fromJson(json.lineSymbol);
        }
        if (json.pointSymbol) {
          json.pointSymbol = jsonUtils.fromJson(json.pointSymbol);
        }

        this._processConfig(json).then(lang.hitch(this, function(measurementJson) {
          measurementJson.defaultLengthUnit = esriUnits.KILOMETERS;
          this.measurement = new Measurement(measurementJson, this.measurementDiv);
          this.own(aspect.after(this.measurement, 'setTool', lang.hitch(this, function() {
            if (this.measurement.activeTool) {
              this.disableWebMapPopup();
            } else {
              this.enableWebMapPopup();
            }
          })));
          this.measurement.startup();

          this.measurement._distanceUnitStrings = ["Kilometers", "Meters"];
          this.measurement._distanceUnitStringsLong = ["esriKilometers", "esriMeters"];

          this._hideToolsByConfig();
        }), lang.hitch(this, function(err) {
          new Message({
            message: err.message || err
          });
        }));
      },

View solution in original post

2 Replies
RobertScheitlin__GISP
MVP Emeritus

Liorit,

   In the Widget.js you can add this code:

Line 17 I am setting the default length unit to Kilometers.

Line 28 and 29 I am removing Miles as an option.

      startup: function() {
        if (this.measurement || this._pcDef) {
          return;
        }
        this.inherited(arguments);

        var json = this.config.measurement;
        json.map = this.map;
        if (json.lineSymbol) {
          json.lineSymbol = jsonUtils.fromJson(json.lineSymbol);
        }
        if (json.pointSymbol) {
          json.pointSymbol = jsonUtils.fromJson(json.pointSymbol);
        }

        this._processConfig(json).then(lang.hitch(this, function(measurementJson) {
          measurementJson.defaultLengthUnit = esriUnits.KILOMETERS;
          this.measurement = new Measurement(measurementJson, this.measurementDiv);
          this.own(aspect.after(this.measurement, 'setTool', lang.hitch(this, function() {
            if (this.measurement.activeTool) {
              this.disableWebMapPopup();
            } else {
              this.enableWebMapPopup();
            }
          })));
          this.measurement.startup();

          this.measurement._distanceUnitStrings = ["Kilometers", "Meters"];
          this.measurement._distanceUnitStringsLong = ["esriKilometers", "esriMeters"];

          this._hideToolsByConfig();
        }), lang.hitch(this, function(err) {
          new Message({
            message: err.message || err
          });
        }));
      },
GuillaumeDENIAUD
Occasional Contributor

I would answer for Clément whose traineeship is over :

"Thank you Robert, that was exactly what I was looking for"

I can't close directly this ticket for him but we can consider it as close.

Thanks

0 Kudos