Select to view content in your preferred language

Problem with Toolset Deactivating - Edit Tools and Delete Toolset

768
2
10-03-2013 09:28 AM
IanPeebles
Frequent Contributor
I have recently added two toolsets into an application.  These toolsets includ:

1. Editing (includes move, edit vertices, scale, rotate and options)
2. Delete (from operational base)

The problem is that the Delete Tool will not fire when all other Editing tools are not checked.  When the Move tool is checked, the delete tool will work when it is checked.  My intention is for these toolsets to be separate, so when the Delete tool is checked, the Edit Tools are deactivated.  Right now, they seem to work together.

Is there a way I can deactivate the edit tools when the delete tool is checked and deactivate the delete tool when any of the editing tools are checked.

I have attached a copy of the application as a .zip file that uses ESRI data as an example.  Both toolsets are included within the application.


I appreciate any assistance.
0 Kudos
2 Replies
IanPeebles
Frequent Contributor
Still looking for some input.  Here is the code block I am working with right now.  The first post contains the entire application.

//  *****************************************************************************
//  *   EDIT FEATURES - MOVE, EDIT VERTICES, SCALE, ROTATE, OPTIONS             *
//  *****************************************************************************   
        function createEditToolbar() {
      var activeFeatureLayer = null;
         var landuseLayerFL = map.getLayer("landuseLayer");
   var militaryareasFL = map.getLayer("militaryareas");
            editModifyFeaturesTools = new esri.toolbars.Edit(map);

            // ACTIVATE TOOLBAR WHEN CLICKING ON PLANTING SITES
            dojo.connect(landuseLayerFL, "onClick", function(evt) {
               dojo.stopEvent(evt);
               activateEditToolbar(evt.graphic);
      activeFeatureLayer = landuseLayerFL;
            });
  
      // ACTIVATE TOOLBAR WHEN CLICKING ON PUBLIC TREE INVENTORY
      dojo.connect(militaryareasFL, "onClick", function(evt) {
              dojo.stopEvent(evt);
              activateEditToolbar(evt.graphic);
     activeFeatureLayer = militaryareasFL;
            });
   
   // DEACTIVATE TOOLBAR
            dojo.connect(map,"onClick", function(evt){
            editModifyFeaturesTools.deactivate();
            });
        
   // POST EDITS AFTER TOOL IS DEACTIVATED
   dojo.connect(editModifyFeaturesTools, "onDeactivate", function(editTool,graphic) {
               activeFeatureLayer.applyEdits(null, [graphic], null);
      alert("Feature successfully updated.");
            });
   
        }

     // ACTIVATE TOOLBAR EDITING
        function activateEditToolbar(graphic) {
            var editTool = 0;
        
            if (dijit.byId("tool_move").checked) {
                editTool = editTool | esri.toolbars.Edit.MOVE;    
            }
            if (dijit.byId("tool_vertices").checked) {
                editTool = editTool | esri.toolbars.Edit.EDIT_VERTICES; 
            }
            if (dijit.byId("tool_scale").checked) {
                editTool = editTool | esri.toolbars.Edit.SCALE; 
            }
            if (dijit.byId("tool_rotate").checked) {
                editTool = editTool | esri.toolbars.Edit.ROTATE; 
            }
      
      // SPECIFY TOOLBAR OPTIONS
            var options = {
                allowAddVertices: dijit.byId("vtx_ca").checked,
                allowDeleteVertices: dijit.byId("vtx_cd").checked,
                uniformScaling: dijit.byId("uniform_scaling").checked
            };
            editModifyFeaturesTools.activate(editTool, graphic, options);
   
        }
  
//  *****************************************************************************
//  *   DELETE FEATURES                                                         *
//  *****************************************************************************  
 function editingDeleteFeature(results) {
  var layers = dojo.map(results, function (result) {
  return result.layer;
    });

    // DELETE FEATURE USING ONCLICK
    dojo.forEach(layers, function (deleteFeatureslLayer) {
  dojo.connect(deleteFeatureslLayer, "onClick", function (evt) {
        dojo.stopEvent(evt);

        // DELETE FEATURE IS DELETE BUTTON IS CHECKED (ACTIVE)
        if (dijit.byId("tool_delete").checked) {
            deleteFeatureslLayer.applyEdits(null, null, [evt.graphic], function () {
              operation = new esri.dijit.editing.Delete({
                    featureLayer: deleteFeatureslLayer,
                    deletedGraphics: [evt.graphic]
     });
     // ALERT WHEN FEATURE IS DELETED
     alert("Feature deleted.")
    });
   }
  });
 });

} 
0 Kudos
IanPeebles
Frequent Contributor
Does anyone have and feedback?
0 Kudos