From d954c08b2954af22f857376b7b6f1ee00d4cb11c Mon Sep 17 00:00:00 2001 From: Speeder Date: Sat, 30 Dec 2023 20:23:35 +0100 Subject: [PATCH] Added a Google Multipoint route planner option --- index.html | 6 ++++ res/huroutes.js | 81 ++++++++++++++++++++++++++++++++++++------------- 2 files changed, 66 insertions(+), 21 deletions(-) diff --git a/index.html b/index.html index 8aefa3f..913b2ba 100644 --- a/index.html +++ b/index.html @@ -82,6 +82,12 @@ 'rating': 'Az útvonal értékelése vezethetőség, változatosság, izgalom szempontjaiból.', 'navToPoi': ' Navigáció ehhez a helyhez.', 'sharePoi': 'Hely megosztása.', + 'nav': { + 'Google follow route': 'Google útvonal követés' + }, + 'nav-label': { + 'Google follow route': 'Hosszabb útvonalak esetén előfordulhat pontatlan tervezés.' + }, 'navLength': 'Az útvonal hossza.', 'navStartTooltip': 'Navigálás az útvonal elejére.', 'navEndTooltip': 'Navigálás az útvonal végére.', diff --git a/res/huroutes.js b/res/huroutes.js index 6387650..94534f8 100644 --- a/res/huroutes.js +++ b/res/huroutes.js @@ -35,18 +35,39 @@ const huroutes = { }, // A list of navigation service providers that can be chosen for the "navigate to" links'. // The default provider used is the first one. + // The getLink attribute is function(destination, waypoints). + // The waypoints attribute defines the number of waypoints passed to the getLink function. 'navLinkProviders': { - 'Google': coord => { - const link = 'https://www.google.com/maps/dir/?api=1&travelmode=driving&destination={0},{1}'; - return link.format(coord.lat, coord.lng); + 'Google': { + 'getLink': dst => { + const link = 'https://www.google.com/maps/dir/?api=1&travelmode=driving&destination={0},{1}'; + return link.format(dst.lat, dst.lng); + }, + 'waypoints': 0 }, - 'Waze': coord => { - const link = 'https://www.waze.com/ul?ll={0}%2C{1}&navigate=yes'; - return link.format(coord.lat, coord.lng); + 'Google follow route': { + 'getLink': (dst, wpts) => { + // Undocumented URI for multi-waypoint route planning. + // The double-slash after dir means an unknown starting coordinate. + // The data means determine starting location and start directions. + const link = 'https://www.google.com/maps/dir//{0}/{1},{2}/data=!4m6!4m5!1m1!4e2!1m0!1m0!3e0'; + return link.format(wpts.map(c => c.lat + ',' + c.lng).join('/'), dst.lat, dst.lng); + }, + 'waypoints': 8 // The starting location and destination are not part of this. }, - 'Apple': coord => { - const link = 'http://maps.apple.com/?daddr={0},{1}&dirflg=d'; - return link.format(coord.lat, coord.lng); + 'Waze': { + 'getLink': dst => { + const link = 'https://www.waze.com/ul?ll={0}%2C{1}&navigate=yes'; + return link.format(dst.lat, dst.lng); + }, + 'waypoints': 0 + }, + 'Apple': { + 'getLink': dst => { + const link = 'http://maps.apple.com/?daddr={0},{1}&dirflg=d'; + return link.format(dst.lat, dst.lng); + }, + 'waypoints': 0 } }, // Route path data download formats. @@ -500,7 +521,7 @@ function addRoute(data) for (var i = 1; i < coords.length; ++i) length += coords[i - 1].distanceTo(coords[i]); var elemLinks = $('