- // 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: OSM.GRAPHHOPPER_URL,
+ data: {
+ vehicle: vehicleType,
+ locale: I18n.currentLocale(),
+ key: "LijBPDQGfu7Iiq80w3HzwB4RUDJbMbhs6BU0dEnn",
+ elevation: false,
+ instructions: true,
+ turn_costs: vehicleType === "car",
+ point: points.map(function (p) { return p.lat + "," + p.lng; })
+ },
+ traditional: true,
+ dataType: "json",