Measure widget - default values

106
5
a week ago
New Contributor II

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

NovicaJ_0-1610580446221.png

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

Tags (3)
Reply
0 Kudos
5 Replies
Regular Contributor

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

Reply
0 Kudos
New Contributor II

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

NovicaJ_0-1610582639241.png

 

 

Reply
0 Kudos
Regular Contributor

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
}
Reply
0 Kudos
New Contributor II

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. 

NovicaJ_0-1610583957468.png

 

Reply
0 Kudos
Regular Contributor

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.

Reply
0 Kudos