- // https://github.com/graphhopper/directions-api/blob/master/docs-routing.md
- var url = document.location.protocol + "//graphhopper.com/api/1/route?" +
- vehicleParam +
- "&locale=" + I18n.currentLocale() +
- "&key=LijBPDQGfu7Iiq80w3HzwB4RUDJbMbhs6BU0dEnn" +
- "&type=jsonp" +
- "&elevation=false" +
- "&instructions=true";
-
- for (var i = 0; i < points.length; i++) {
- url += "&point=" + points[i].lat + ',' + points[i].lng;
- }
-
- $.ajax({
- url: url,
- dataType: 'jsonp',
+ // 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",