AnsweredAssumed Answered

Need help with polygon union operation using JavaScript 3.6 API with undo, redo

Question asked by tgroussell on Sep 12, 2013
Latest reply on Sep 12, 2013 by tgroussell
I am trying to implement a polygon union operation using ArcGIS 10.2 JavaScript 3.6 API with undo, redo capabilities. I am able to perform the union operation, but when I try to undo the operation I get the following error:

Unhandled exception at line 19, column 1879 in http://js.arcgis.com/3.6/js/esri/dijit/editing/Cut.js

0x800a138f - JavaScript runtime error: Unable to get property 'length' of undefined or null reference

Code Snippet:

dojo.connect(dijit.byId("Merge_Button"), "onClick", function () {     editing_function = "Merge_From";     document.getElementById("Status_Message").innerHTML = "Select Polygon to Merge From"     esri.bundle.toolbars.draw.addPoint = "Select Polygon to Merge From";     drawToolbar.activate(esri.toolbars.Draw.POINT); });  dojo.connect(drawToolbar, "onDrawEnd", function (geometry) {  if (editing_function == "Merge_From") {     var point_selectQuery = new esri.tasks.Query();     point_selectQuery.geometry = geometry;      edit_featurelayer.selectFeatures(point_selectQuery, esri.layers.FeatureLayer.SELECTION_NEW, function (features) {         if (features.length == 0) {             r = confirm("Nothing Selected. Try again?");             if (r == true) {                 return;             }             drawToolbar.deactivate();             document.getElementById("Status_Message").innerHTML = "Nothing exciting going on around here";             return         }         merge_from_features = features;         editing_function = "Merge_To";         document.getElementById("Status_Message").innerHTML = "Select Polygon to Merge To";         esri.bundle.toolbars.draw.addPoint = "Select Polygon to Merge To";     });     return; }  if (editing_function == "Merge_To") {     var point_selectQuery = new esri.tasks.Query();     point_selectQuery.geometry = geometry;     edit_featurelayer.selectFeatures(point_selectQuery, esri.layers.FeatureLayer.SELECTION_ADD, function (features) {         if (features.length == 0) {             r = confirm("Nothing Selected. Try again?");             if (r == true) {                 return;             }             drawToolbar.deactivate();             document.getElementById("Status_Message").innerHTML = "Nothing exciting going on around here";             return         }         merge_to_features = features;         editing_function = "";         document.getElementById("Status_Message").innerHTML = "Nothing exciting going on around here";         drawToolbar.deactivate();          var input_geometries;         try {              var from_g = merge_from_features[0].geometry;             var to_g = merge_to_features[0].geometry;             var input_geometries = [from_g, to_g];              geometryService.union(input_geometries, function (unioned_geometry) {                 var merge_from_feature = merge_from_features[0];                 var merge_to_feature = merge_to_features[0];                  var original_feature = merge_to_feature.toJson();                 merge_to_feature.geometry = unioned_geometry;                  edit_featurelayer.applyEdits(null, [merge_to_feature], [merge_from_feature], function () {                     try {                          var operation = new esri.dijit.editing.Union({                             deleted_graphics: [merge_from_feature],                             featureLayer: edit_featurelayer,                             preUpdatedGraphics: new esri.Graphic(original_feature),                             postUpdatedGraphics: [merge_to_feature]                         });                      }                     catch (err) {                         alert(err.message);                     };                     undoManager.add(operation);                     checkUI();                 });             });         }         catch (err) {             alert(err.message);         };     });       return; };  drawToolbar.deactivate();

Outcomes