AnsweredAssumed Answered

Calculating acres from Edit Widget pop-up window

Question asked by rmueller1@dow.com on Apr 1, 2016

I am trying to allow a user to calculate geometry for a predefined field from the Edit widget pop-up window using the ESRI JS geometryEngine. So far I've added a button to the Edit widget pop-up (in place of the close button), and assigning a variable to the selected features. However, Firebug tells me there is an error on this line in the geometryengine.js

                   

                    var CalcAcres=geometryEngine.geodesicArea(SelectedPoly, "acres")

 

Anyone have an idea on what's going on? My current thinking is that I'm doing to much in the "addButtonToInspector" and need to move the calculation somewhere outside this function

  _addButtonToInspector: function() {

        /*var closeButton = new Button({

          label: esriBundle.common.close,

          "class": " atiButton closeButton"

        }, html.create("div"));

        */

       

        //Swapping out the CalcAcresButton for the "close" button

        var CalcAcresButton = new Button({

          label: "Calculate Acres",

          "class": " atiButton CalcAcresButton"

        }, html.create("div"));

       

        html.place(CalcAcresButton.domNode,

                   this.editor.attributeInspector.deleteBtn.domNode,

                   "after");

        this.own(on(CalcAcresButton, 'click', lang.hitch(this, function() {

       

                //Get Selected polygon

              var SelectedPoly = this.map.infoWindow.getSelectedFeature();

              //Calculate the acreage, store in avariable

              //Either "acres" or 109403

              var CalcAcres=geometryEngine.geodesicArea(SelectedPoly, "acres");

              //setting the value for the "Acres" field for with the calculated value

              featureLayer.setAttributes({"Acres":CalcAcres});

             //Applying the edits to the featurelayer

             this.featureLayer.applyEdits(null, [featureLayer], null);

         

        })));

      },

Outcomes