Hello,
first of all thanks for your work on this great service.
So, I wanted to implement the result of an isochrone request on my leaflet basemap using the leaflet plugin for your service: https://github.com/traffordDataLab/leaflet.reachability
But I can’t really figure out how to make the isochrone request after initializing the plugin. Maybe someone could me out here? Or is there an easier way to add the result of the request from the website to a leaflet map?
Request parameter:
let request = new XMLHttpRequest();
request.open('POST', "https://api.openrouteservice.org/v2/isochrones/driving-car");
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', 'api key');
request.onreadystatechange = function () {
if (this.readyState === 4) {
console.log('Status:', this.status);
console.log('Headers:', this.getAllResponseHeaders());
console.log('Body:', this.responseText);
}
};
const body = '{"locations":[[10.992193,47.456659]],"range":[3600],"attributes":["total_pop"]}';
request.send(body);
Leaflet Map"
<script type='text/javascript'>
var Karte = L.map('Karte').setView([48.896465, 10.996526], 7);
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
'attribution': 'Kartendaten © <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> Mitwirkende',
'useCache': true
}).addTo(Karte);
// Initialise the reachability plugin
L.control.reachability({
// add settings/options here
apiKey: 'api key'
}).addTo(map);
</script>
Help would be much appreciated