X-Git-Url: https://git.openstreetmap.org/rails.git/blobdiff_plain/3ef8024b1d33f0de6227a26967ba78ef85672a94..9126653ffd07e38800986a6410ae1fe0955989fc:/app/assets/javascripts/routing_engines/graphhopper.js diff --git a/app/assets/javascripts/routing_engines/graphhopper.js b/app/assets/javascripts/routing_engines/graphhopper.js index 5c10433c2..0f29c162b 100644 --- a/app/assets/javascripts/routing_engines/graphhopper.js +++ b/app/assets/javascripts/routing_engines/graphhopper.js @@ -1,6 +1,7 @@ GraphHopperEngine = function(vehicleName, vehicleParam, locale) { this.vehicleName = vehicleName; this.vehicleParam = vehicleParam; + //At this point the local system isn't correctly initialised yet, so we don't have accurate information about current locale this.locale = locale; if (!locale) this.locale = "en"; @@ -10,12 +11,13 @@ GraphHopperEngine.prototype.createConfig = function() { var that = this; return { name: "javascripts.directions.engines.graphhopper_"+this.vehicleName.toLowerCase(), + creditline: 'Graphhopper', draggable: false, _hints: {}, getRoute: function(isFinal, points) { var url = "http://graphhopper.com/routing/api/route?" + that.vehicleParam - + "&locale=" + that.locale; + + "&locale=" + I18n.currentLocale(); for (var i = 0; i < points.length; i++) { var pair = points[i].join(','); url += "&point=" + pair; @@ -42,7 +44,7 @@ GraphHopperEngine.prototype.createConfig = function() { instrText += instr.descriptions[i]; var latlng = instr.latLngs[i]; var distInMeter = instr.distances[i]; - steps.push([{lat: latlng[0], lng: latlng[1]}, instrCode, instrText, distInMeter]); + steps.push([{lat: latlng[0], lng: latlng[1]}, instrCode, instrText, distInMeter, []]); // TODO does graphhopper map instructions onto line indices? } router.setItinerary({ steps: steps, distance: data.route.distance, time: data.route['time']/1000 }); return true; @@ -59,5 +61,5 @@ GraphHopperEngine.prototype.createConfig = function() { }; }; -OSM.RoutingEngines.list.push(new GraphHopperEngine("Bicycle", "vehicle=bike").createConfig()); -OSM.RoutingEngines.list.push(new GraphHopperEngine("Foot", "vehicle=foot").createConfig()); +OSM.RoutingEngines.add(false, new GraphHopperEngine("Bicycle", "vehicle=bike").createConfig()); +OSM.RoutingEngines.add(false, new GraphHopperEngine("Foot", "vehicle=foot").createConfig());