+ getRoute: function (points, signal) {
+ // GraphHopper Directions API documentation
+ // https://graphhopper.com/api/1/docs/routing/
+ const query = new URLSearchParams({
+ vehicle: vehicleType,
+ locale: I18n.currentLocale(),
+ key: "LijBPDQGfu7Iiq80w3HzwB4RUDJbMbhs6BU0dEnn",
+ elevation: false,
+ instructions: true,
+ turn_costs: vehicleType === "car"
+ });
+ points.forEach(p => query.append("point", p.lat + "," + p.lng));
+ return fetch(OSM.GRAPHHOPPER_URL + "?" + query, { signal })
+ .then(response => response.json())
+ .then(({ paths }) => {
+ if (!paths || paths.length === 0) throw new Error();
+ return _processDirections(paths[0]);