Measure widget - default values

01-13-2021 03:28 PM
by Anonymous User
Not applicable

I am trying to set the default values in the Measure widget. As shown below, the highlighted toggle button by default is on. I am trying to set it to off by default


Can I do this somehow? How do I set it to off by default? 

Tags (3)
0 Kudos
6 Replies
Occasional Contributor III

You can control the areas to be visible by changing to false under the configs/measurement

0 Kudos
by Anonymous User
Not applicable

Can I kindly ask to you elaborate? This is what the config.json file looks like for my Measure widget. 




0 Kudos
Occasional Contributor III

Is it a custom widget? What version of WAB are you using?

The measurement widget in WAB has this config.json

  "measurement": {
    "defaultAreaUnit": "esriAcres",
    "defaultLengthUnit": "esriMiles"
  "showArea": true,
  "showDistance": true,
  "showLocation": true,
  "defaultAreaUnit": "esriSquareMiles",
  "defaultLengthUnit": "esriMiles",
  "isOperationalLayer": false
0 Kudos
by Anonymous User
Not applicable

Yes, it it a custom widget, so to say. It's a combination of the draw and measure widgets. 
I attached the Widget.js file for your viewing pleasure. 

As for the config for the widget, I tried adding the following but the toggle button is still toggled on. 



0 Kudos
Occasional Contributor III

By adding the in the config file with no action in js, it wont do anything. You will need to add the action under the postCreate function to read the setting in the config like:


initialstate= this.config.showDistance


Then, disable or enable the visibility of the "show distance measurement" div depending on the initial state value. However, if the toggle button is in the same div as the "show distance measurement" , and the div is not enabled,  you will not be able to click on it and enable it on later. The button needs to be outside. Hope it makes sense.

0 Kudos
New Contributor III

I'm by no means a Developer...  One of our staff insists on 'the simplest of apps.'  Which means I'm poking code until it breaks, then undoing my last poke.

I had the opposite problem in the Draw Widget.  Toggles were off by default, when I wanted them selected.

In the #\widgets\Draw\Widget.html, I made an alteration:

<div data-dojo-attach-point="areaMeasure" class="draw-item jimu-symbol-chooser">
<div class="header applied" data-dojo-attach-point="areaMeasureHeader" data-index="areaMeasure">
<!-- <span class="arrow jimu-float-leading jimu-trailing-margin05" ></span> -->
<span class="item-title">${nls.showAreaMeasurement}</span>
<span class="toggle-draw jimu-trailing-margin1" data-dojo-attach-point="areaToggleDraw"></span>

<span class="toggle-draw jimu-trailing-margin1 jimu-toggle-button checked" data-dojo-attach-point="areaToggleDraw" id="jimu_dijit_ToggleButton_1" widgetid="jimu_dijit_ToggleButton_1" role="button" tabindex="0" aria-pressed="true"></span>

I'm not really done poking yet, but this change had the desired effect: selecting an area draw tool and using it immediately adds the area label.

Tags (1)
0 Kudos