Using OSR Request with Leaflet

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:

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();'POST', "");

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"]}';

Leaflet Map"
<script type='text/javascript'>
    var Karte ='Karte').setView([48.896465, 10.996526], 7);  
     L.tileLayer('https://{s}{z}/{x}/{y}.png', {
     'attribution':  'Kartendaten &copy; <a href="">OpenStreetMap</a> Mitwirkende',
     'useCache': true

	// Initialise the reachability plugin
        // add settings/options here 
        apiKey: 'api key'


Help would be much appreciated :slight_smile:

1 Like

Hi @mat109,

thank you so much for sharing this, i was not aware this plugin exists.

The isochrone request is made by the leaflet control itself.
You just have to click on the map it seems.

Did you run this example?
just copy paste it into an html file (or download) and open it in your browser.

To generate isochrones press the draw button and click somewhere on the map.
you can adjust the mode (time, distance), the profile and the time or distance limit to prefilled values.

If you use the script part from that file and adjust it to your needs you should be able to get somewhere.

Best regards

1 Like

Thanks for the quick response and the link.
Must have missed it earlier, now it works as I wanted to. It’s a neat plugin actually.

Best wishes