Select to view content in your preferred language

Measure Widget Custom Text WAB

1412
3
Jump to solution
04-11-2017 11:39 AM
Anish_Adhikari
Occasional Contributor

I am trying to add a new line of custom text right before the Measurement Results Label in WAB developer edition and have not yet been able to figure out. I would greatly appreciate any help.

0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Emeritus

Anish,

  Sure, in the Widget.js make these additions (lines 12 - 14, 27 - 29 and 43-45):

define([
    'dojo/_base/declare',
    'dojo/_base/lang',
    'dojo/aspect',
    'dojo/Deferred',
    'dijit/_WidgetsInTemplateMixin',
    'jimu/BaseWidget',
    'jimu/portalUtils',
    'jimu/dijit/Message',
    'esri/units',
    'esri/dijit/Measurement',
    "esri/symbols/jsonUtils",
    'dojo/query',
    'dojo/dom-construct'
  ],
  function(
    declare,
    lang,
    aspect,
    Deferred,
    _WidgetsInTemplateMixin,
    BaseWidget,
    PortalUtils,
    Message,
    esriUnits,
    Measurement,
    jsonUtils,
    query,
    domContruct) {

.....

      _hideToolsByConfig: function() {
        if (false === this.config.showArea) {
          this.measurement.hideTool("area");
        }
        if (false === this.config.showDistance) {
          this.measurement.hideTool("distance");
        }
        if (false === this.config.showLocation) {
          this.measurement.hideTool("location");
        }
        var node = query(".esriMeasurementResultLabel", this.measurement.domNode)[0];
        var note = domContruct.toDom("<span>Blah blah</span>");
        domContruct.place(note, node, "before");
      },

View solution in original post

3 Replies
RobertScheitlin__GISP
MVP Emeritus

Anish,

  Sure, in the Widget.js make these additions (lines 12 - 14, 27 - 29 and 43-45):

define([
    'dojo/_base/declare',
    'dojo/_base/lang',
    'dojo/aspect',
    'dojo/Deferred',
    'dijit/_WidgetsInTemplateMixin',
    'jimu/BaseWidget',
    'jimu/portalUtils',
    'jimu/dijit/Message',
    'esri/units',
    'esri/dijit/Measurement',
    "esri/symbols/jsonUtils",
    'dojo/query',
    'dojo/dom-construct'
  ],
  function(
    declare,
    lang,
    aspect,
    Deferred,
    _WidgetsInTemplateMixin,
    BaseWidget,
    PortalUtils,
    Message,
    esriUnits,
    Measurement,
    jsonUtils,
    query,
    domContruct) {

.....

      _hideToolsByConfig: function() {
        if (false === this.config.showArea) {
          this.measurement.hideTool("area");
        }
        if (false === this.config.showDistance) {
          this.measurement.hideTool("distance");
        }
        if (false === this.config.showLocation) {
          this.measurement.hideTool("location");
        }
        var node = query(".esriMeasurementResultLabel", this.measurement.domNode)[0];
        var note = domContruct.toDom("<span>Blah blah</span>");
        domContruct.place(note, node, "before");
      },
Anish_Adhikari
Occasional Contributor

Robert, this worked great. You have been super helpful as always.

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Great,  don't forget to mark this as answered then.

0 Kudos