I’m trying to get a very simple example working, and failing…
I have a client browser with existing features, and am trying to add a Route-Planning feature.
I’m currently trying to run this Directions example:
var Directions = new Openrouteservice.Directions({ api_key: "Yes_I_Have_A_Key"});
Directions.calculate({
coordinates: [[8.690958, 49.404662], [8.687868, 49.390139]],
profile: 'driving-car',
// profile:
// {
// "vehicle_type": "driving-car",
// "avoid_features": "ferries|tollways",
// "maximum_speed": 100,
// },
extra_info: ['waytype', 'steepness'],
avoid_features: ['tollways', 'ferries'],
format: 'json'
})
.then(function(json) {
// Add your own result handling here
console.log(JSON.stringify(json));
})
.catch(function(err) {
var str = "An error occurred: " + err;
console.log(str);
});
}
** Problem 1: If I run the code as is, I get these 2 errors:
ors-js-client.js:16 POST https://api.openrouteservice.org/v2/directions/driving-car/json 400
ors-js-client.js:36 Error: Unsuccessful HTTP response
at Request. (ors-js-client.js:16)
at Request.Emitter.emit (ors-js-client.js:7)
at XMLHttpRequest.t.onreadystatechange (ors-js-client.js:16)
I understand that the second error is the result of the first, but have been unable to find any useful documentation on the source of the first error
** Problem 2: How do I use the extended profile features?
If I replace: profile: ‘driving-car’,
with the commented lines below it, then the ‘driving-car’ field in the POST command never even gets populated
I would appreciate help with these problems, and if there is a working example that you can point me to that would be great!