Realtime Flight Tracking Map

Mapbox powered tracking of flights in and out of SFO airport in San Francisco, California.

Embed

var pubnub = new PubNub({
  publishKey: 'demo',
  subscribeKey: 'demo'
});
var map = eon.map({
  id: 'map',
  mbId: 'YOUR_MAPBOX_ID',
  mbToken: 'YOUR_MAPBOX_TOKEN',
  pubnub: pubnub,
  channels: ['sfo-flight-data'],
  rotate: true,
  history: true,
  marker: function (latlng, data) {

    var marker = new L.RotatedMarker(latlng, {
      icon: L.icon({
        iconUrl: '/wp-content/uploads/2016/05/airplane.png',
        iconSize: [24, 24]
      })
    });

    var popup = '';
    if(data[13]) {
      popup = 'Flight ' + data[13] + '';
    }
    if(data[11]) {
      if(!popup.length) {
        popup = 'Flight from ' + data[11];
      } else {
        popup += ' from ' + data[11];
      }
    }
    if(data[12]) {
      if(!popup.length) {
        popup = 'Flight to ' + data[12];
      } else {
        popup += ' to ' + data[12];
      }
    }
    if(!popup.length) {
      var popup = 'No data available';
    }

    marker.bindPopup(popup);

    return marker;
  }
});

Publish

var pubnub = new PubNub({
  publishKey: 'demo',
  subscribeKey: 'demo'
});
setInterval(function(){

  PUBNUB.publish({
    channel: 'sfo-flight-data',
    message:  
      {
        66e234a: {
           latlng: [
             37.6271,
             -122.3858
           ],
           data: [
             "A33D8C",
             37.6271,
             -122.3858,
             118,
             0,
             23,
             "3765",
             "F-KSJC3",
             "DC10",
             "N308FE",
             1433383239,
             "SFO",
             "MEM",
             "FX1345",
             1,
             0,
             "FDX1345",
             0
           ]
         },
         //...
      }
  });

}, 1000);

Try PubNub Today

Connect up to 100 devices for Free