var airfields = L.layerGroup(); var airfields_active = L.layerGroup(); var task_lines = L.layerGroup(); var map = L.map('map', { center: [51.7119539, -2.1352713], zoom: 7, minZoom: 6, maxZoom: 9 }); L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { attribution: '© OpenStreetMap contributors' }).addTo(map); /*L.tileLayer('https://{s}.basemaps.cartocdn.com/rastertiles/voyager_nolabels/{z}/{x}/{y}.png', { maxZoom: 18 }).addTo(map); L.tileLayer('https://{s}.basemaps.cartocdn.com/rastertiles/voyager_only_labels/{z}/{x}/{y}.png', { maxZoom: 18, zIndex: 10 }).addTo(map);*/ var bounds = L.latLngBounds(); airfield = L.circle([57.07568000, -2.84504000], 2000, {color: '#fa0', fillColor: '#fa0', fillOpacity: 0.5}).addTo(map).bindPopup('Aboyne
'); airfield.id = 1; airfields.addLayer(airfield); airfield = L.circle([54.37316000, -4.42918000], 2000, {color: '#fa0', fillColor: '#fa0', fillOpacity: 0.5}).addTo(map).bindPopup('Andreas
'); airfield.id = 2; airfields.addLayer(airfield); airfield = L.circle([51.71218000, -2.12612000], 2000, {color: '#fa0', fillColor: '#fa0', fillOpacity: 0.5}).addTo(map).bindPopup('Aston Down
118.665'); airfield.id = 3; airfields.addLayer(airfield); airfield = L.circle([51.91297000, -1.14034000], 2000, {color: '#fa0', fillColor: '#fa0', fillOpacity: 0.5}).addTo(map).bindPopup('Bicester
'); airfield.id = 5; airfields.addLayer(airfield); airfield = L.circle([52.14113000, -1.84533000], 2000, {color: '#fa0', fillColor: '#fa0', fillOpacity: 0.5}).addTo(map).bindPopup('Bidford
'); airfield.id = 6; airfields.addLayer(airfield); airfield = L.circle([50.80256000, -0.66471000], 2000, {color: '#fa0', fillColor: '#fa0', fillOpacity: 0.5}).addTo(map).bindPopup('Bognor Regis
'); airfield.id = 7; airfields.addLayer(airfield); airfield = L.circle([53.88616000, -2.61998000], 2000, {color: '#fa0', fillColor: '#fa0', fillOpacity: 0.5}).addTo(map).bindPopup('Bowland Forest
'); airfield.id = 8; airfields.addLayer(airfield); airfield = L.circle([53.74956000, -1.09707000], 2000, {color: '#fa0', fillColor: '#fa0', fillOpacity: 0.5}).addTo(map).bindPopup('Burn
'); airfield.id = 9; airfields.addLayer(airfield); airfield = L.circle([53.30354000, -1.72804000], 2000, {color: '#fa0', fillColor: '#fa0', fillOpacity: 0.5}).addTo(map).bindPopup('Camphill
'); airfield.id = 10; airfields.addLayer(airfield); airfield = L.circle([51.17927000, 1.28005000], 2000, {color: '#fa0', fillColor: '#fa0', fillOpacity: 0.5}).addTo(map).bindPopup('Channel Gliding Club
'); airfield.id = 11; airfields.addLayer(airfield); airfield = L.circle([52.71151000, -0.13386000], 2000, {color: '#fa0', fillColor: '#fa0', fillOpacity: 0.5}).addTo(map).bindPopup('Crowland
'); airfield.id = 12; airfields.addLayer(airfield); airfield = L.circle([53.24776000, -0.85156000], 2000, {color: '#fa0', fillColor: '#fa0', fillOpacity: 0.5}).addTo(map).bindPopup('Darlton
'); airfield.id = 13; airfields.addLayer(airfield); airfield = L.circle([50.59155000, -4.15237000], 2000, {color: '#fa0', fillColor: '#fa0', fillOpacity: 0.5}).addTo(map).bindPopup('Dartmoor Gliding Society
'); airfield.id = 14; airfields.addLayer(airfield); airfield = L.circle([50.71240000, -2.21756000], 2000, {color: '#fa0', fillColor: '#fa0', fillOpacity: 0.5}).addTo(map).bindPopup('Dorset Gliding Club
'); airfield.id = 15; airfields.addLayer(airfield); airfield = L.circle([54.94311000, -3.74090000], 2000, {color: '#fa0', fillColor: '#fa0', fillOpacity: 0.5}).addTo(map).bindPopup('Dumfries & District Gliding Club
'); airfield.id = 16; airfields.addLayer(airfield); airfield = L.circle([51.87309000, -0.54952000], 2000, {color: '#fa0', fillColor: '#fa0', fillOpacity: 0.5}).addTo(map).bindPopup('Dunstable
'); airfield.id = 17; airfields.addLayer(airfield); airfield = L.circle([50.92788000, -3.98482000], 2000, {color: '#fa0', fillColor: '#fa0', fillOpacity: 0.5}).addTo(map).bindPopup('Eaglescott
'); airfield.id = 18; airfields.addLayer(airfield); airfield = L.circle([57.58701900, -3.30376900], 2000, {color: '#fa0', fillColor: '#fa0', fillOpacity: 0.5}).addTo(map).bindPopup('Easterton
'); airfield.id = 19; airfields.addLayer(airfield); airfield = L.circle([51.93161000, -1.44181000], 2000, {color: '#fa0', fillColor: '#fa0', fillOpacity: 0.5}).addTo(map).bindPopup('Enstone
'); airfield.id = 20; airfields.addLayer(airfield); airfield = L.circle([57.10602000, -3.88713000], 2000, {color: '#fa0', fillColor: '#fa0', fillOpacity: 0.5}).addTo(map).bindPopup('Feshiebridge
'); airfield.id = 21; airfields.addLayer(airfield); airfield = L.circle([52.16606000, -0.11736000], 2000, {color: '#fa0', fillColor: '#fa0', fillOpacity: 0.5}).addTo(map).bindPopup('Gransden Lodge
'); airfield.id = 22; airfields.addLayer(airfield); airfield = L.circle([51.25990000, -2.72914000], 2000, {color: '#fa0', fillColor: '#fa0', fillOpacity: 0.5}).addTo(map).bindPopup('Halesland
'); airfield.id = 23; airfields.addLayer(airfield); airfield = L.circle([52.03207000, -1.21141000], 2000, {color: '#fa0', fillColor: '#fa0', fillOpacity: 0.5}).addTo(map).bindPopup('Hinton in the Hedges
'); airfield.id = 24; airfields.addLayer(airfield); airfield = L.circle([52.43718000, -1.05176000], 2000, {color: '#fa0', fillColor: '#fa0', fillOpacity: 0.5}).addTo(map).bindPopup('Husbands Bosworth
127.580'); airfield.id = 25; airfields.addLayer(airfield); airfield = L.circle([51.30124000, -0.09377000], 2000, {color: '#fa0', fillColor: '#fa0', fillOpacity: 0.5}).addTo(map).bindPopup('Kenley
'); airfield.id = 26; airfields.addLayer(airfield); airfield = L.circle([51.20946000, 0.83103000], 2000, {color: '#fa0', fillColor: '#fa0', fillOpacity: 0.5}).addTo(map).bindPopup('Kent Gliding Club
'); airfield.id = 27; airfields.addLayer(airfield); airfield = L.circle([53.45953000, -0.58266000], 2000, {color: '#fa0', fillColor: '#fa0', fillOpacity: 0.5}).addTo(map).bindPopup('Kirton in Lindsey
'); airfield.id = 28; airfields.addLayer(airfield); airfield = L.circle([51.19024000, -1.03260000], 2000, {color: '#fa0', fillColor: '#fa0', fillOpacity: 0.5}).addTo(map).bindPopup('Lasham
131.030'); airfield.id = 29; airfields.addLayer(airfield); airfield = L.circle([50.82069000, -1.20324000], 2000, {color: '#fa0', fillColor: '#fa0', fillOpacity: 0.5}).addTo(map).bindPopup('Lee on Solent
'); airfield.id = 30; airfields.addLayer(airfield); airfield = L.circle([53.04657000, -3.21909000], 2000, {color: '#fa0', fillColor: '#fa0', fillOpacity: 0.5}).addTo(map).bindPopup('Llantysilio
'); airfield.id = 31; airfields.addLayer(airfield); airfield = L.circle([53.20826000, -3.39429000], 2000, {color: '#fa0', fillColor: '#fa0', fillOpacity: 0.5}).addTo(map).bindPopup('Lleweni Parc
'); airfield.id = 32; airfields.addLayer(airfield); airfield = L.circle([52.51860000, -2.88080000], 2000, {color: '#fa0', fillColor: '#fa0', fillOpacity: 0.5}).addTo(map).bindPopup('Long Mynd
'); airfield.id = 34; airfields.addLayer(airfield); airfield = L.circle([52.46360000, -0.58309000], 2000, {color: '#fa0', fillColor: '#fa0', fillOpacity: 0.5}).addTo(map).bindPopup('Lyveden
'); airfield.id = 35; airfields.addLayer(airfield); airfield = L.circle([55.58941000, -2.08443000], 2000, {color: '#fa0', fillColor: '#fa0', fillOpacity: 0.5}).addTo(map).bindPopup('Milfield
'); airfield.id = 36; airfields.addLayer(airfield); airfield = L.circle([52.43215000, -0.14722000], 2000, {color: '#fa0', fillColor: '#fa0', fillOpacity: 0.5}).addTo(map).bindPopup('Nene Valley Gliding Club
'); airfield.id = 37; airfields.addLayer(airfield); airfield = L.circle([50.85286000, -3.26734000], 2000, {color: '#fa0', fillColor: '#fa0', fillOpacity: 0.5}).addTo(map).bindPopup('North Hill
'); airfield.id = 38; airfields.addLayer(airfield); airfield = L.circle([54.93437000, -1.83919000], 2000, {color: '#fa0', fillColor: '#fa0', fillOpacity: 0.5}).addTo(map).bindPopup('Northumbria Gliding Club
'); airfield.id = 39; airfields.addLayer(airfield); airfield = L.circle([51.71520000, -2.28302000], 2000, {color: '#fa0', fillColor: '#fa0', fillOpacity: 0.5}).addTo(map).bindPopup('Nympsfield
129.980'); airfield.id = 40; airfields.addLayer(airfield); airfield = L.circle([50.92187000, -0.47398000], 2000, {color: '#fa0', fillColor: '#fa0', fillOpacity: 0.5}).addTo(map).bindPopup('Parham
'); airfield.id = 41; airfields.addLayer(airfield); airfield = L.circle([53.92176000, -0.79143000], 2000, {color: '#fa0', fillColor: '#fa0', fillOpacity: 0.5}).addTo(map).bindPopup('Pocklington
'); airfield.id = 42; airfields.addLayer(airfield); airfield = L.circle([56.18904000, -3.32183000], 2000, {color: '#fa0', fillColor: '#fa0', fillOpacity: 0.5}).addTo(map).bindPopup('Portmoak
'); airfield.id = 43; airfields.addLayer(airfield); airfield = L.circle([52.64489000, -2.30922000], 2000, {color: '#fa0', fillColor: '#fa0', fillOpacity: 0.5}).addTo(map).bindPopup('RAF Cosford
'); airfield.id = 44; airfields.addLayer(airfield); airfield = L.circle([53.04079000, -0.50246000], 2000, {color: '#fa0', fillColor: '#fa0', fillOpacity: 0.5}).addTo(map).bindPopup('RAF Cranwell
'); airfield.id = 45; airfields.addLayer(airfield); airfield = L.circle([51.78629000, -0.73624000], 2000, {color: '#fa0', fillColor: '#fa0', fillOpacity: 0.5}).addTo(map).bindPopup('RAF Halton
'); airfield.id = 46; airfields.addLayer(airfield); airfield = L.circle([51.30392330, -2.12192770], 2000, {color: '#fa0', fillColor: '#fa0', fillOpacity: 0.5}).addTo(map).bindPopup('RAF Keevil
'); airfield.id = 47; airfields.addLayer(airfield); airfield = L.circle([57.58643300, -3.32121900], 2000, {color: '#fa0', fillColor: '#fa0', fillOpacity: 0.5}).addTo(map).bindPopup('RAF Kinloss
'); airfield.id = 48; airfields.addLayer(airfield); airfield = L.circle([52.65241000, 0.54509000], 2000, {color: '#fa0', fillColor: '#fa0', fillOpacity: 0.5}).addTo(map).bindPopup('RAF Marham
'); airfield.id = 49; airfields.addLayer(airfield); airfield = L.circle([51.24046000, -0.94521000], 2000, {color: '#fa0', fillColor: '#fa0', fillOpacity: 0.5}).addTo(map).bindPopup('RAF Odiham
'); airfield.id = 50; airfields.addLayer(airfield); airfield = L.circle([51.88102000, -1.22785000], 2000, {color: '#fa0', fillColor: '#fa0', fillOpacity: 0.5}).addTo(map).bindPopup('RAF Weston on the Green
'); airfield.id = 51; airfields.addLayer(airfield); airfield = L.circle([52.16959000, 0.87509000], 2000, {color: '#fa0', fillColor: '#fa0', fillOpacity: 0.5}).addTo(map).bindPopup('Rattlesden
'); airfield.id = 52; airfields.addLayer(airfield); airfield = L.circle([52.04953000, 0.55768000], 2000, {color: '#fa0', fillColor: '#fa0', fillOpacity: 0.5}).addTo(map).bindPopup('Ridgewell
'); airfield.id = 53; airfields.addLayer(airfield); airfield = L.circle([50.90914000, 0.10553000], 2000, {color: '#fa0', fillColor: '#fa0', fillOpacity: 0.5}).addTo(map).bindPopup('Ringmer
'); airfield.id = 54; airfields.addLayer(airfield); airfield = L.circle([51.33725000, -1.54452000], 2000, {color: '#fa0', fillColor: '#fa0', fillOpacity: 0.5}).addTo(map).bindPopup('Rivar Hill
'); airfield.id = 55; airfields.addLayer(airfield); airfield = L.circle([50.08176000, -5.25784000], 2000, {color: '#fa0', fillColor: '#fa0', fillOpacity: 0.5}).addTo(map).bindPopup('RNAS Culdrose
'); airfield.id = 56; airfields.addLayer(airfield); airfield = L.circle([51.01358000, -2.64780000], 2000, {color: '#fa0', fillColor: '#fa0', fillOpacity: 0.5}).addTo(map).bindPopup('RNAS Yeovilton
'); airfield.id = 57; airfields.addLayer(airfield); airfield = L.circle([53.94222000, -1.18997000], 2000, {color: '#fa0', fillColor: '#fa0', fillOpacity: 0.5}).addTo(map).bindPopup('Rufforth
'); airfield.id = 58; airfields.addLayer(airfield); airfield = L.circle([52.26210000, -0.47764000], 2000, {color: '#fa0', fillColor: '#fa0', fillOpacity: 0.5}).addTo(map).bindPopup('Sackville
'); airfield.id = 59; airfields.addLayer(airfield); airfield = L.circle([52.83020000, -0.70029000], 2000, {color: '#fa0', fillColor: '#fa0', fillOpacity: 0.5}).addTo(map).bindPopup('Saltby
'); airfield.id = 60; airfields.addLayer(airfield); airfield = L.circle([51.60698000, -1.66949000], 2000, {color: '#fa0', fillColor: '#fa0', fillOpacity: 0.5}).addTo(map).bindPopup('Sandhill Farm
129.980'); airfield.id = 61; airfields.addLayer(airfield); airfield = L.circle([52.82777000, -2.20900000], 2000, {color: '#fa0', fillColor: '#fa0', fillOpacity: 0.5}).addTo(map).bindPopup('Seighford
'); airfield.id = 62; airfields.addLayer(airfield); airfield = L.circle([52.08017000, -1.47345000], 2000, {color: '#fa0', fillColor: '#fa0', fillOpacity: 0.5}).addTo(map).bindPopup('Shenington
'); airfield.id = 63; airfields.addLayer(airfield); airfield = L.circle([52.24344000, -2.88381000], 2000, {color: '#fa0', fillColor: '#fa0', fillOpacity: 0.5}).addTo(map).bindPopup('Shobdon
'); airfield.id = 64; airfields.addLayer(airfield); airfield = L.circle([54.69345000, -2.57918000], 2000, {color: '#fa0', fillColor: '#fa0', fillOpacity: 0.5}).addTo(map).bindPopup('Skelling Farm
'); airfield.id = 65; airfields.addLayer(airfield); airfield = L.circle([52.83391000, -2.76763000], 2000, {color: '#fa0', fillColor: '#fa0', fillOpacity: 0.5}).addTo(map).bindPopup('Sleap
'); airfield.id = 66; airfields.addLayer(airfield); airfield = L.circle([52.23568000, -1.71059000], 2000, {color: '#fa0', fillColor: '#fa0', fillOpacity: 0.5}).addTo(map).bindPopup('Snitterfield
'); airfield.id = 67; airfields.addLayer(airfield); airfield = L.circle([53.30342000, 0.16814000], 2000, {color: '#fa0', fillColor: '#fa0', fillOpacity: 0.5}).addTo(map).bindPopup('Strubby
'); airfield.id = 68; airfields.addLayer(airfield); airfield = L.circle([54.22883000, -1.20964000], 2000, {color: '#fa0', fillColor: '#fa0', fillOpacity: 0.5}).addTo(map).bindPopup('Sutton Bank
'); airfield.id = 69; airfields.addLayer(airfield); airfield = L.circle([51.97914000, -3.20344000], 2000, {color: '#fa0', fillColor: '#fa0', fillOpacity: 0.5}).addTo(map).bindPopup('Talgarth
'); airfield.id = 70; airfields.addLayer(airfield); airfield = L.circle([51.13063900, -2.22628200], 2000, {color: '#fa0', fillColor: '#fa0', fillOpacity: 0.5}).addTo(map).bindPopup('The Park
'); airfield.id = 71; airfields.addLayer(airfield); airfield = L.circle([52.45721000, 1.16124000], 2000, {color: '#fa0', fillColor: '#fa0', fillOpacity: 0.5}).addTo(map).bindPopup('Tibenham
'); airfield.id = 72; airfields.addLayer(airfield); airfield = L.circle([55.13789000, -6.96489000], 2000, {color: '#fa0', fillColor: '#fa0', fillOpacity: 0.5}).addTo(map).bindPopup('Ulster Gliding Club
'); airfield.id = 73; airfields.addLayer(airfield); airfield = L.circle([51.29101000, -1.77913000], 2000, {color: '#fa0', fillColor: '#fa0', fillOpacity: 0.5}).addTo(map).bindPopup('Upavon
'); airfield.id = 74; airfields.addLayer(airfield); airfield = L.circle([51.71792000, -2.84326000], 2000, {color: '#fa0', fillColor: '#fa0', fillOpacity: 0.5}).addTo(map).bindPopup('Usk
'); airfield.id = 75; airfields.addLayer(airfield); airfield = L.circle([54.12518000, -3.26031000], 2000, {color: '#fa0', fillColor: '#fa0', fillOpacity: 0.5}).addTo(map).bindPopup('Walney
'); airfield.id = 76; airfields.addLayer(airfield); airfield = L.circle([52.12280000, 0.96776000], 2000, {color: '#fa0', fillColor: '#fa0', fillOpacity: 0.5}).addTo(map).bindPopup('Wattisham
'); airfield.id = 77; airfields.addLayer(airfield); airfield = L.circle([51.94407000, 0.80292000], 2000, {color: '#fa0', fillColor: '#fa0', fillOpacity: 0.5}).addTo(map).bindPopup('Wormingford
'); airfield.id = 78; airfields.addLayer(airfield); airfield = L.circle([51.61017000, -0.80107000], 2000, {color: '#fa0', fillColor: '#fa0', fillOpacity: 0.5}).addTo(map).bindPopup('Wycombe Air Park
'); airfield.id = 79; airfields.addLayer(airfield); //var openaip_cached_basemap = new L.TileLayer("http://{s}.tile.maps.openaip.net/geowebcache/service/tms/1.0.0/openaip_basemap@EPSG%3A900913@png/{z}/{x}/{y}.png", { var openaip_cached_basemap = new L.TileLayer("https://skylines.aero/mapproxy/tiles/1.0.0/airspace+airports/EPSG3857/{z}/{x}/{y}.png", { // tms: true, // detectRetina: true, // subdomains: '12', // format: 'image/png', // transparent: true, opacity: 0.8, attribution: 'Airspace from openAIP' }); var flying = false; var pending_event = null; $.each(airfields.getLayers(),function(index, el){ el.bringToFront(); }); $.each(airfields_active.getLayers(),function(index, el){ el.bringToFront(); }); if (bounds.isValid()) { map.fitBounds(bounds, {maxZoom: 8}); } $('.airfield-pan').click(function($e){ $e.preventDefault(); id = $(this).data('id'); airfields_active.eachLayer(function(layer){ if (layer.id == id) { pending_event = layer; } }); airfields.eachLayer(function(layer){ if (layer.id == id) { pending_event = layer; } }); map.flyTo($(this).data('coord'), 9); flying = true; }); map.on('moveend', function(e){ if (flying) { if (pending_event != null) { pending_event.openPopup(); pending_event = null; } flying = false; } }); $('.task-pan').click(function($e){ $e.preventDefault(); map.flyTo($(this).data('coord'), 9); }); L.easyButton({ states: [{ stateName: 'show-airspace', icon: 'glyphicon-screenshot', title: 'Show airspace', onClick: function(btn, map) { map.addLayer(openaip_cached_basemap); btn.state('hide-airspace'); } }, { stateName: 'hide-airspace', icon: 'glyphicon-ban-circle', title: 'Hide airspace', onClick: function(btn, map) { map.removeLayer(openaip_cached_basemap); btn.state('show-airspace'); } }] }).addTo(map);