Saturday, 11 August 2018

javascript - Configurable Map Viewer (CMV) - select by drawing polygon around points, then average the values of the points


I have seen this question and have tried the code suggested: Adapting ESRI ArcGIS API for JavaScript Feature Layer With Selection sample for use in Configurable Map Viewer (CMV)


But I have been unable to get it to work. I also want to change the result from the sum to the average.


Here is my error report from chrome development tools My error report



Answer




For your first issue: it appears that the template file for your widget is missing, inaccessible or corrupt. Based on the code posted in the linked example, the template file is './Select/templates/Select.html'. Check that file to ensure it is valid.


For your second issue: to do a simple average, you would take the sum calculated in the example code this.productionSum and divide by the number of features event.features.length. Something like:


this.productionAVG = (this.productionSum / event.features.length)

Be sure to handle a possible divide by zero error in the cases where no features are returned by the selection.


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...