X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/2b252e8337109de714bb8aa38ccf6d46e7686e42..904b5129981657c2d0228a27d8bdfc167b42ac27:/app/assets/javascripts/index/directions_engines/graphhopper.js?ds=inline diff --git a/app/assets/javascripts/index/directions_engines/graphhopper.js b/app/assets/javascripts/index/directions_engines/graphhopper.js index d6e52070c..8d01bcd16 100644 --- a/app/assets/javascripts/index/directions_engines/graphhopper.js +++ b/app/assets/javascripts/index/directions_engines/graphhopper.js @@ -1,4 +1,4 @@ -function GraphHopperEngine(vehicleName, vehicleParam) { +function GraphHopperEngine(id, vehicleParam) { var GH_INSTR_MAP = { "-3": 6, // sharp left "-2": 7, // left @@ -12,26 +12,24 @@ function GraphHopperEngine(vehicleName, vehicleParam) { }; return { - name: "javascripts.directions.engines.graphhopper_" + vehicleName.toLowerCase(), - creditline: 'Graphhopper', + id: id, + creditline: 'Graphhopper', draggable: false, - getRoute: function (isFinal, points, callback) { + getRoute: function (points, callback) { // documentation // https://github.com/graphhopper/graphhopper/blob/master/docs/web/api-doc.md - var url = "http://graphhopper.com/api/1/route?" + var url = "https://graphhopper.com/api/1/route?" + vehicleParam + "&locale=" + I18n.currentLocale() + "&key=LijBPDQGfu7Iiq80w3HzwB4RUDJbMbhs6BU0dEnn" - + "&type=jsonp"; + + "&type=jsonp" + + "&instructions=true"; for (var i = 0; i < points.length; i++) { url += "&point=" + points[i].lat + ',' + points[i].lng; } - if (isFinal) - url += "&instructions=true"; - $.ajax({ url: url, dataType: 'jsonp', @@ -72,5 +70,5 @@ function GraphHopperEngine(vehicleName, vehicleParam) { }; } -OSM.Directions.addEngine(GraphHopperEngine("Bicycle", "vehicle=bike"), false); -OSM.Directions.addEngine(GraphHopperEngine("Foot", "vehicle=foot"), false); +OSM.Directions.addEngine(GraphHopperEngine("graphhopper_bicycle", "vehicle=bike"), false); +OSM.Directions.addEngine(GraphHopperEngine("graphhopper_foot", "vehicle=foot"), false);