forked from flightaware/dump1090
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlayers.js
103 lines (90 loc) · 3.64 KB
/
layers.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
// -*- mode: javascript; indent-tabs-mode: nil; c-basic-offset: 8 -*-
"use strict";
// Base layers configuration
function createBaseLayers() {
var layers = [];
var world = [];
var us = [];
world.push(new ol.layer.Tile({
source: new ol.source.OSM(),
name: 'osm',
title: 'OpenStreetMap',
type: 'base',
}));
if (BingMapsAPIKey) {
world.push(new ol.layer.Tile({
source: new ol.source.BingMaps({
key: BingMapsAPIKey,
imagerySet: 'Aerial'
}),
name: 'bing_aerial',
title: 'Bing Aerial',
type: 'base',
}));
world.push(new ol.layer.Tile({
source: new ol.source.BingMaps({
key: BingMapsAPIKey,
imagerySet: 'Road'
}),
name: 'bing_roads',
title: 'Bing Roads',
type: 'base',
}));
}
if (ChartBundleLayers) {
var chartbundleTypes = {
sec: "Sectional Charts",
tac: "Terminal Area Charts",
hel: "Helicopter Charts",
enrl: "IFR Enroute Low Charts",
enra: "IFR Area Charts",
enrh: "IFR Enroute High Charts"
};
for (var type in chartbundleTypes) {
us.push(new ol.layer.Tile({
source: new ol.source.TileWMS({
url: 'http://wms.chartbundle.com/wms',
params: {LAYERS: type},
projection: 'EPSG:3857',
attributions: 'Tiles courtesy of <a href="http://www.chartbundle.com/">ChartBundle</a>'
}),
name: 'chartbundle_' + type,
title: chartbundleTypes[type],
type: 'base',
group: 'chartbundle'}));
}
}
var nexrad = new ol.layer.Tile({
name: 'nexrad',
title: 'NEXRAD',
type: 'overlay',
opacity: 0.5,
visible: false
});
us.push(nexrad);
var refreshNexrad = function() {
// re-build the source to force a refresh of the nexrad tiles
var now = new Date().getTime();
nexrad.setSource(new ol.source.XYZ({
url : 'http://mesonet{1-3}.agron.iastate.edu/cache/tile.py/1.0.0/nexrad-n0q-900913/{z}/{x}/{y}.png?_=' + now,
attributions: 'NEXRAD courtesy of <a href="http://mesonet.agron.iastate.edu/">IEM</a>'
}));
};
refreshNexrad();
window.setInterval(refreshNexrad, 5 * 60000);
if (world.length > 0) {
layers.push(new ol.layer.Group({
name: 'world',
title: 'Worldwide',
layers: world
}));
}
if (us.length > 0) {
layers.push(new ol.layer.Group({
name: 'us',
title: 'US',
layers: us
}));
}
return layers;
}