- // documentation
- // https://github.com/graphhopper/graphhopper/blob/master/docs/web/api-doc.md
- var url = "https://graphhopper.com/api/1/route?"
- + vehicleParam
- + "&locale=" + I18n.currentLocale()
- + "&key=LijBPDQGfu7Iiq80w3HzwB4RUDJbMbhs6BU0dEnn"
- + "&type=jsonp"
- + "&instructions=true";
-
- for (var i = 0; i < points.length; i++) {
- url += "&point=" + points[i].lat + ',' + points[i].lng;
- }
-
- $.ajax({
- url: url,
- dataType: 'jsonp',
+ // GraphHopper Directions API documentation
+ // https://graphhopper.com/api/1/docs/routing/
+ return $.ajax({
+ url: document.location.protocol + OSM.GRAPHHOPPER_URL,
+ data: {
+ vehicle: vehicleType,
+ locale: I18n.currentLocale(),
+ key: "LijBPDQGfu7Iiq80w3HzwB4RUDJbMbhs6BU0dEnn",
+ "ch.disable": vehicleType === "car",
+ type: "jsonp",
+ elevation: false,
+ instructions: true,
+ point: points.map(function (p) { return p.lat + "," + p.lng; })
+ },
+ traditional: true,
+ dataType: "jsonp",