I’m resurrecting a website that was functioning with the v1 api. I’ve changed the call to the new format, but my code that processes the geojson isn’t working anymore. Did the format change? I’m having a hard time because the chrome debugger isn’t showing the response in hierarchical form anymore. Sorry if this is a dumb question, I’ve just been banging my head against the wall.
let request = new XMLHttpRequest();
request.open('POST', "https://api.openrouteservice.org/v2/directions/foot-walking/geojson", false);
request.setRequestHeader('Accept', 'application/json, application/geo+json, application/gpx+xml, img/png; charset=utf-8');
request.setRequestHeader('Content-Type', 'application/json');
request.setRequestHeader('Authorization', 'xxx');
request.onreadystatechange = function () {
if (this.readyState === 4) {
console.log('Status:', this.status);
console.log('Headers:', this.getAllResponseHeaders());
//console.log('Body:', this.responseText);
}
};
reqbody = '{"coordinates":[[-114.2531,48.97598],[-114.10499,48.96443]],"elevation":"true"}';
request.send(reqbody);
// code to process the response that is failing with NOT FOUND (with Leaflet)
$.getJSON(request.response, function(routeline) {
var routeLayer = L.geoJson(routeline.features[0].geometry, {
onEachFeature: function (feature, layer) {
layer.setStyle({
‘color’ : ‘red’
});
}
});