diff --git a/js/index.js b/js/index.js index 2a66b6d..280fa46 100644 --- a/js/index.js +++ b/js/index.js @@ -32,9 +32,10 @@ trackMessages, sidebar, drawButton, - deleteButton, + deleteRouteButton, drawToolbar, urlHash, + reverseRoute, saveWarningShown = false; // By default bootstrap-select use glyphicons @@ -70,7 +71,23 @@ }] }); - deleteButton = L.easyButton( + reverseRouteButton = L.easyButton( + 'fa-random', + function () { + routing.reverse(); + }, + i18next.t('map.reverse-route') + ); + + deletePointButton = L.easyButton( + '', + function () { + routing.removeWaypoint(routing.getLast()); + }, + i18next.t('map.delete-last-point') + ); + + deleteRouteButton = L.easyButton( 'fa-trash-o', function () { bootbox.prompt({ @@ -227,7 +244,7 @@ routing.addTo(map); elevation.addBelow(map); - + sidebar = BR.sidebar({ defaultTabId: BR.conf.transit ? 'tab_itinerary' : 'tab_profile', listeningTabs: { @@ -240,7 +257,7 @@ } nogos.addTo(map); - drawToolbar = L.easyBar([drawButton, nogos.getButton(), deleteButton]).addTo(map); + drawToolbar = L.easyBar([drawButton, reverseRouteButton, nogos.getButton(), deletePointButton, deleteRouteButton]).addTo(map); nogos.preventRoutePointOnCreate(routing); if (BR.keys.strava) { diff --git a/js/plugin/Routing.js b/js/plugin/Routing.js index 4f45c29..cfb3241 100644 --- a/js/plugin/Routing.js +++ b/js/plugin/Routing.js @@ -299,4 +299,11 @@ BR.Routing = L.Routing.extend({ ,isDrawing: function () { return this._draw._enabled; } + + ,reverse: function() { + var waypoints = this.getWaypoints(); + waypoints.reverse(); + this.clear(); + this.setWaypoints(waypoints); + } }); diff --git a/locales/en.json b/locales/en.json index 1190d03..d71082a 100644 --- a/locales/en.json +++ b/locales/en.json @@ -61,6 +61,7 @@ "clear-route": "Clear route", "copyright": "Copyright", "cycling": "Cycling", + "delete-last-point": "Delete last point", "delete-nogo-areas": "  also delete all no-go areas", "delete-route": "Delete route?", "draw-route-start": "Draw route (D key)", @@ -93,6 +94,7 @@ }, "opacity-slider": "Set transparency of route track and markers", "privacy": "Privacy", + "reverse-route": "Reverse route", "strava-biking": "Show Strava biking segments", "strava-running": "Show Strava running segments", "zoomInTitle": "Zoom in",