Add shortcut to delete last point

Press 'Z' to undo adding the last point.
This commit is contained in:
Henrik Fehlauer 2020-06-05 18:00:00 +00:00
parent a852acbfce
commit 48f8fe3524
3 changed files with 10 additions and 3 deletions

View file

@ -84,7 +84,7 @@
var deletePointButton = L.easyButton(
'<span><i class="fa fa-caret-left"></i><i class="fa fa-map-marker" style="margin-left: 1px; color: gray;"></i></span>',
function() {
routing.removeWaypoint(routing.getLast(), function(err, data) {});
routing.deleteLastPoint();
},
i18next.t('map.delete-last-point')
);

View file

@ -29,7 +29,8 @@ BR.Routing = L.Routing.extend({
enable: 68, // char code for 'd'
disable: 27 // char code for 'ESC'
},
reverse: 82 // char code for 'r'
reverse: 82, // char code for 'r'
deleteLastPoint: 90 // char code for 'z'
}
},
@ -352,6 +353,8 @@ BR.Routing = L.Routing.extend({
this._draw.enable();
} else if (e.keyCode === this.options.shortcut.reverse) {
this.reverse();
} else if (e.keyCode === this.options.shortcut.deleteLastPoint) {
this.deleteLastPoint();
}
},
@ -374,6 +377,10 @@ BR.Routing = L.Routing.extend({
this.setWaypoints(waypoints);
},
deleteLastPoint: function() {
this.removeWaypoint(this.getLast(), function(err, data) {});
},
_removeDistanceMarkers: function() {
if (this._map && this._distanceMarkers) {
this._map.removeLayer(this._distanceMarkers);

View file

@ -82,7 +82,7 @@
"clear-route": "Clear route data",
"copyright": "Copyright",
"cycling": "Cycling",
"delete-last-point": "Delete last point",
"delete-last-point": "Delete last point (Z key)",
"delete-nogo-areas": "Delete all no-go areas",
"delete-pois": "Delete all points of interest",
"delete-route": "Delete route",