css Audio - Active file-generic CSS - Active Generic - Active HTML - Active JS - Active SVG - Active Text - Active file-generic Video - Active header Love html icon-new-collection icon-person icon-team numbered-list123 pop-out spinner split-screen star tv

Pen Settings

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation


Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

              <body style="margin: 0px 0px">
  <div id="map_isochrone" style="height:100vh;"/>
  var map = L.map('map_isochrone',{
    scrollWheelZoom : false
  }).setView([50.85, 4.4], 8);
  L.tileLayer('https://{s}.tile.thunderforest.com/transport/{z}/{x}/{y}.png', {
    attribution: '&copy; <a href="http://osm.org/copyright">OpenStreetMap</a> contributors'

  //Create our stations list on the basis of the iRail API
  var stations = {};
  var markers = {
    "http://irail.be/stations/NMBS/008892007" : true,//Gent
    "http://irail.be/stations/NMBS/008891009" : true,//Luik
    "http://irail.be/stations/NMBS/008841004" : true,//Brugge
    "http://irail.be/stations/NMBS/008821006" : true,//Antwerpen
    "http://irail.be/stations/NMBS/008863008" : true,//Namur
    "http://irail.be/stations/NMBS/008844404" : true,//Spa
    "http://irail.be/stations/NMBS/008866258" : true,//Neuf-Château
    "http://irail.be/stations/NMBS/008866001" : true,//Arlon
    "http://irail.be/stations/NMBS/008812005" : true //Brussel Noord
  var blueIcon = L.icon({
      iconUrl : 'https://linkedconnections.org/images/marker-icon.png',
//      iconRetinaUrl : 'https://linkedconnections.org/images/marker-icon-2x.png',
      iconAnchor: [12, 41]
  $.get("https://api.irail.be/stations.php?format=json", function (stationslist) {
    stationslist.station.forEach(function (station) {
      var key = station["@id"];
      stations[key] = {
        longitude : station.locationX,
        latitude : station.locationY,
        name : station.name,
        '@id' : station['@id'],
        point : new L.LatLng(station.locationY, station.locationX)
      if (markers[key]) {
        markers[key] = L.marker([station.locationY, station.locationX]).setIcon(blueIcon).addTo(map);
        markers[key].on("click", function () {
          handleClick(key, markers[key]);
    var startIcon = L.icon({
      iconUrl : 'http://linkedconnections.org/images/marker-icon-start.png',
      iconRetinaUrl: 'http://linkedconnections.org/images/marker-icon-2x-start.png'

    L.Icon.Default.iconUrl = 'http://linkedconnections.org/images/marker-icon.png';
    L.Icon.Default.iconRetinaUrl = 'http://linkedconnections.org/images/marker-icon-2x.png';
    var planner = new window.lc.Client({"entrypoints" : ["https://graph.irail.be/sncb/connections"]});
    var departureStop = "";
    var arrivalStop = "";
    var handleClick = function (station, marker) {
      if (departureStop === "") {
        for (key in markers) {
        departureStop = station;
        var startTime = new Date();
          "departureStop": departureStop,
          "departureTime": startTime
        }, function (stream) {
          var drawIsochrone = function (howFarHours, color, connection) {
            var secondsFromStart = (connection.arrivalTime - startTime)/1000;              
            var howFar = (howFarHours)*60*60; //how far can we get in 3 hours
            var radius = (howFar - secondsFromStart)*1.39; //we assume 1.39m/s as a walking speed
            if (radius < 0) {
            L.circle(connection.arrivalStop.point, radius, {
              color: color,
              stroke : false,
              weight: 1,
              fillOpacity: 0.10,
              fillRule : "nonzero"
          var trips = {};
          var countTrips = 0;
          stream.on('data', function (connection) {
            if (stations[connection.arrivalStop] && stations[connection.departureStop]) {
              connection.arrivalStop = stations[connection.arrivalStop];
              connection.departureStop = stations[connection.departureStop];
              //circle for the isochrone to be drawn
              //Keep an occurence of different trips and give a new colour per trip
              //polyline for the path visualization
              var polyline = new L.Polyline([connection.departureStop.point, connection.arrivalStop.point], {
                color: "red",
                weight: 2.5,
                smoothFactor: 1
            } else {
              connection.arrivalStop = {
                name : connection.arrivalStop
              connection.departureStop = {
                name : connection.arrivalStop
          stream.on('error', function (error) {
          stream.on('end', function () {
            console.log('end of stream');

🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.
Loading ..................