First, Thanks, @TomSellsted, for a great widget. I have found it very helpful.
I did note a minor issue that I am unsure how to clean up. If you draw a multipart polygon or line and press 'ESC' to quit the sketch, the line or polygon is removed, but the labels remain. Also, the widget remains in draw mode, and behavior is erratic if you continue to use the widget.
How can the widget be modified to remove the active text symbols and cleanly terminate the current sketch?
Sketching:
After pressing 'ESC', labels remain
Behavior after: Cannot see the first segment until the second click and only the last label is displayed upon completion.
Solved! Go to Solution.
I was able to fix this by adding a 'keydown' bind event in the postCreate function. I could only get it to work by binding it to the document.body. Added a conditional to stop the propagation of the 'ESC' if measure.Type is set and to also exit editing if editing is enabled.
this.own(on(document.body, "keydown", lang.hitch(this, function(evt) {
if(evt.keyCode == keys.ESCAPE) {
if(this.measureType) {
event.stop(evt);
} else if (this.editingEnabled) {
this.editToolbar.deactivate();
this.editingEnabled = false;
}
}
}
I was able to fix this by adding a 'keydown' bind event in the postCreate function. I could only get it to work by binding it to the document.body. Added a conditional to stop the propagation of the 'ESC' if measure.Type is set and to also exit editing if editing is enabled.
this.own(on(document.body, "keydown", lang.hitch(this, function(evt) {
if(evt.keyCode == keys.ESCAPE) {
if(this.measureType) {
event.stop(evt);
} else if (this.editingEnabled) {
this.editToolbar.deactivate();
this.editingEnabled = false;
}
}
}