From d009aa5bc6cd276231b611ab3b7594f59ae3d273 Mon Sep 17 00:00:00 2001 From: Gautier Pelloux-Prayer Date: Sat, 11 May 2019 17:48:37 +0200 Subject: [PATCH 1/3] Add reverse route button --- js/index.js | 13 +++++++++++-- js/plugin/Routing.js | 7 +++++++ locales/en.json | 1 + 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/js/index.js b/js/index.js index 2a66b6d..2527191 100644 --- a/js/index.js +++ b/js/index.js @@ -35,6 +35,7 @@ deleteButton, drawToolbar, urlHash, + reverseRoute, saveWarningShown = false; // By default bootstrap-select use glyphicons @@ -70,6 +71,14 @@ }] }); + reverseRouteButton = L.easyButton( + 'fa-random', + function () { + routing.reverse(); + }, + i18next.t('map.reverse-route') + ); + deleteButton = L.easyButton( 'fa-trash-o', function () { @@ -227,7 +236,7 @@ routing.addTo(map); elevation.addBelow(map); - + sidebar = BR.sidebar({ defaultTabId: BR.conf.transit ? 'tab_itinerary' : 'tab_profile', listeningTabs: { @@ -240,7 +249,7 @@ } nogos.addTo(map); - drawToolbar = L.easyBar([drawButton, nogos.getButton(), deleteButton]).addTo(map); + drawToolbar = L.easyBar([drawButton, reverseRouteButton, nogos.getButton(), deleteButton]).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..982149d 100644 --- a/locales/en.json +++ b/locales/en.json @@ -93,6 +93,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", From 191f6b25a810a133873ce49204caced8b06a6298 Mon Sep 17 00:00:00 2001 From: Gautier Pelloux-Prayer Date: Sun, 12 May 2019 10:32:32 +0200 Subject: [PATCH 2/3] Add delete last point button --- js/index.js | 14 +++++++++++--- locales/en.json | 1 + 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/js/index.js b/js/index.js index 2527191..2c97813 100644 --- a/js/index.js +++ b/js/index.js @@ -32,7 +32,7 @@ trackMessages, sidebar, drawButton, - deleteButton, + deleteRouteButton, drawToolbar, urlHash, reverseRoute, @@ -79,7 +79,15 @@ i18next.t('map.reverse-route') ); - deleteButton = L.easyButton( + deletePointButton = L.easyButton( + 'fa-undo', + function () { + routing.removeWaypoint(routing.getLast()); + }, + i18next.t('map.delete-last-point') + ); + + deleteRouteButton = L.easyButton( 'fa-trash-o', function () { bootbox.prompt({ @@ -249,7 +257,7 @@ } nogos.addTo(map); - drawToolbar = L.easyBar([drawButton, reverseRouteButton, 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/locales/en.json b/locales/en.json index 982149d..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)", From a3b1a413b07f6d59d06dd2582868465574eac95c Mon Sep 17 00:00:00 2001 From: Gautier Pelloux-Prayer Date: Tue, 14 May 2019 23:03:26 +0200 Subject: [PATCH 3/3] Replace undo icon --- js/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/index.js b/js/index.js index 2c97813..280fa46 100644 --- a/js/index.js +++ b/js/index.js @@ -80,7 +80,7 @@ ); deletePointButton = L.easyButton( - 'fa-undo', + '', function () { routing.removeWaypoint(routing.getLast()); },