AnsweredAssumed Answered

Draw Toolbar onDrawEnd firing twice

Question asked by beck3905 on Sep 16, 2013
Latest reply on Sep 16, 2013 by beck3905
I have a simple editing application with the following code:

startEditing : function(template) {      var drawingTool = template.template.drawingTool;      switch(drawingTool) {         case FeatureTemplate.TOOL_POINT:             drawingTool = Draw.POINT;             break;         }      on(this.drawingToolbar, "draw-end", lang.hitch(this, this.createFeature, template));      this.drawingToolbar.activate(drawingTool); }


and

createFeature : function(template, evt) {      var featureLayer = template.featureLayer;     template = template.template;      var prototype = template.prototype;      var geometry = evt.geometry;      var graphic = new Graphic(prototype.toJson());     graphic.setGeometry(geometry);      this.initAttributes(graphic, featureLayer).then(function() {          var features = [graphic];          featureLayer.applyEdits(features).then(function(addResults) {             var objectIds = array.map(addResults, function(addResult) {                 return addResult.objectId;             });              var q = new Query();             q.objectIds = objectIds;              featureLayer.selectFeatures(q).then(function(features) {                 main.openForm(features);             });         });      });  }


Using a point tool with the drawing toolbar, I am finding that when I click a point on the map, the createFeature function is called twice resulting in 2 features being created with the same geometry.  How can I stop the draw toolbar from creating 2 features?

Outcomes