Select to view content in your preferred language

The Measurement Widget is not working alongside my other widgets

1325
13
Jump to solution
05-08-2023 07:55 AM
ChesouyeCoye
New Contributor III

I am creating a web application and I require the measurement widget, however it does not work alongside my other widgets. It does show up but it does not function and I am not able to see dots, initial points or lines. 

 

Please see application in codepen: 

https://codepen.io/chesouye/pen/ZEqrZwg

 
0 Kudos
1 Solution

Accepted Solutions
KenBuja
MVP Esteemed Contributor

I saw two problems in your script. The first was easily seen in the browser's developer console. You should learn how to use that to see what's going on with your code. The error "Uncaught ReferenceError: activeWidget is not defined" popup up in the console.

It looks like you copied the setActiveFunction script directly from this sample. You left off the line of code to initialize the variable "activeWidget". In the sample, that's on line 63

 

let activeWidget = null;

 

However, just adding that didn't fix the code. Another error popped up, suggesting that the version of the API was not current. Looking at your HTML code, you are using a older version of the API

 

<script src="https://js.arcgis.com/4.11/">

 

If you update that to a newer version, the tool works as expect. However, you cannot update that to the most recent versions, since you are using dojo modules in your script, which were removed after 4.23. You'll have to see which previous version works best for you. And remember to keep the same version for the CSS. Currently, you are using 4.17

 

 <link rel="stylesheet" href="https://js.arcgis.com/4.17/esri/css/main.css">

 

 

View solution in original post

0 Kudos
13 Replies
KenBuja
MVP Esteemed Contributor

I saw two problems in your script. The first was easily seen in the browser's developer console. You should learn how to use that to see what's going on with your code. The error "Uncaught ReferenceError: activeWidget is not defined" popup up in the console.

It looks like you copied the setActiveFunction script directly from this sample. You left off the line of code to initialize the variable "activeWidget". In the sample, that's on line 63

 

let activeWidget = null;

 

However, just adding that didn't fix the code. Another error popped up, suggesting that the version of the API was not current. Looking at your HTML code, you are using a older version of the API

 

<script src="https://js.arcgis.com/4.11/">

 

If you update that to a newer version, the tool works as expect. However, you cannot update that to the most recent versions, since you are using dojo modules in your script, which were removed after 4.23. You'll have to see which previous version works best for you. And remember to keep the same version for the CSS. Currently, you are using 4.17

 

 <link rel="stylesheet" href="https://js.arcgis.com/4.17/esri/css/main.css">

 

 

0 Kudos
ChesouyeCoye
New Contributor III

Thank you for responding and looking at my code. I really appreciate it. I added the changes and it made my mad completely disappear. Im not sure what I am not doing correctly please assist. 

0 Kudos
KenBuja
MVP Esteemed Contributor

I can't tell what you've done. I've made the two edits to your Codepen: https://codepen.io/chesouye/pen/ZEqrZwg?editors=0010

0 Kudos
ChesouyeCoye
New Contributor III

 I saw however the measurement widget still does not work alongside the other widgets. 

0 Kudos
KenBuja
MVP Esteemed Contributor

Some of the other items were broken on the Codepen site that you set up, but when I made those two changes, both the area and distance measurement widgets worked.

area.png

0 Kudos
ChesouyeCoye
New Contributor III

I checked the codepen just now and it didnt work. Im not sure what is happening. I also fixed the css and the other version as suggested. https://codepen.io/chesouye/pen/ZEqrZwg When I click on the measurement icons in the top right it is not functional. No points or lines come up and hence I am not able to measure. 

0 Kudos
KenBuja
MVP Esteemed Contributor

It looks like I gave you the wrong URL. This this one: https://codepen.io/kenbuja/pen/GRYxgMm

0 Kudos
ChesouyeCoye
New Contributor III

Thank you so much. I really appreciate it. Its working well. Again, Thank you. 

0 Kudos
KenBuja
MVP Esteemed Contributor

Please click the "Accept as Solution" button on the post that answered your question. This will help others who may be searching for the same question.

0 Kudos