]> git.openstreetmap.org Git - rails.git/commitdiff
Attach routing credit to route
authorMarwin Hochfelsner <50826859+hlfan@users.noreply.github.com>
Wed, 9 Apr 2025 20:08:29 +0000 (22:08 +0200)
committerAnton Khorev <tony29@yandex.ru>
Thu, 10 Apr 2025 11:03:54 +0000 (14:03 +0300)
app/assets/javascripts/index/directions-route-output.js
app/assets/javascripts/index/directions.js
app/assets/javascripts/index/directions/fossgis_osrm.js
app/assets/javascripts/index/directions/fossgis_valhalla.js
app/assets/javascripts/index/directions/graphhopper.js

index 800181034a8a227c4a8accc6ac0bde46f564f4dc..84bcc87a8d95ef62f47ed2b3b306f810061d5e27 100644 (file)
@@ -52,7 +52,7 @@ OSM.DirectionsRouteOutput = function (map) {
 
   const routeOutput = {};
 
-  routeOutput.write = function (content, engine, route) {
+  routeOutput.write = function (content, route) {
     polyline
       .setLatLngs(route.line)
       .addTo(map);
@@ -117,7 +117,9 @@ OSM.DirectionsRouteOutput = function (map) {
     }</a></p>`);
 
     content.append("<p class=\"text-center\">" +
-      OSM.i18n.t("javascripts.directions.instructions.courtesy", { link: engine.creditline }) +
+      OSM.i18n.t("javascripts.directions.instructions.courtesy", {
+        link: `<a href="${route.creditlink}" target="_blank">${route.credit}</a>`
+      }) +
       "</p>");
   };
 
index ba52d35b309273b8d2558d4958b7b43b5b9d8d53..c5d5cce1589a0d63f6698374546dccedf48eb558 100644 (file)
@@ -107,7 +107,7 @@ OSM.Directions = function (map) {
     map.setSidebarOverlaid(false);
     controller = new AbortController();
     chosenEngine.getRoute(points, controller.signal).then(function (route) {
-      routeOutput.write($("#directions_content"), chosenEngine, route);
+      routeOutput.write($("#directions_content"), route);
       if (fitRoute) {
         routeOutput.fit();
       }
index 40181e588e7679382d47f72a397ff3a5c5fd2eae..53043e06d35366df94da0505c333360f68d6bdf4 100644 (file)
         line: steps.flatMap(step => step[3]),
         steps,
         distance: leg.distance,
-        time: leg.duration
+        time: leg.duration,
+        credit: "OSRM (FOSSGIS)",
+        creditlink: "https://routing.openstreetmap.de/about.html"
       };
     }
 
     return {
       mode: modeId,
       provider: "fossgis_osrm",
-      creditline: "<a href=\"https://routing.openstreetmap.de/about.html\" target=\"_blank\">OSRM (FOSSGIS)</a>",
       draggable: true,
 
       getRoute: function (points, signal) {
index 2e12956577339b61fda00d1af843cea1c3890be6..7354e5d65cd52efb12ae431dfcdd108586a2b55c 100644 (file)
         line,
         steps,
         distance: leg.summary.length * 1000,
-        time: leg.summary.time
+        time: leg.summary.time,
+        credit: "Valhalla (FOSSGIS)",
+        creditlink: "https://gis-ops.com/global-open-valhalla-server-online/"
       };
     }
 
     return {
       mode: modeId,
       provider: "fossgis_valhalla",
-      creditline:
-      "<a href='https://gis-ops.com/global-open-valhalla-server-online/' target='_blank'>Valhalla (FOSSGIS)</a>",
       draggable: false,
 
       getRoute: function (points, signal) {
index 182be4497d38da9481f9a7720de66a4adec2da43..dd79a4671f6b90bcc24ea6b1450f961fc3eb7a5c 100644 (file)
         distance: path.distance,
         time: path.time / 1000,
         ascend: path.ascend,
-        descend: path.descend
+        descend: path.descend,
+        credit: "GraphHopper",
+        creditlink: "https://www.graphhopper.com/"
       };
     }
 
     return {
       mode: modeId,
       provider: "graphhopper",
-      creditline: "<a href=\"https://www.graphhopper.com/\" target=\"_blank\">GraphHopper</a>",
       draggable: false,
 
       getRoute: function (points, signal) {