-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathMMM-Buienradar.js
executable file
·67 lines (56 loc) · 1.36 KB
/
MMM-Buienradar.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
/* Magic Mirror
* Module: MMM-Buienradar
*
* By stefannienhuis
* ISC Licensed.
*/
Module.register("MMM-Buienradar", {
defaults: {
lat: 52.1015474, // Latitude (De Bilt)
lon: 5.1758052, // Longitude (De Bilt)
forecast: true, // Three hour forecast (true) or last hour overview (false)
zoom: 1, // Map zoom level
interval: 10, // Update interval (in minutes)
monochrome: false
},
start: function () {
var self = this;
setInterval(() => {
self.updateDom();
}, this.config.interval * 60000);
},
getStyles: function () {
let styles = ['MMM-Buienradar.css'];
if (this.config.monochrome) {
styles.push('MMM-Buienradar-monochrome.css')
}
return styles;
},
getDom: function () {
var mapContainer = document.createElement('div');
mapContainer.className = 'mapContainer';
var zoom;
switch (this.config.zoom) {
case 4:
zoom = 13;
break;
case 3:
zoom = 11;
break;
case 2:
zoom = 8;
break;
case 1:
zoom = 6;
break;
default:
zoom = 6;
break;
}
var frame = document.createElement('iframe');
frame.className = 'map';
frame.src = 'https://gadgets.buienradar.nl/gadget/zoommap/?lat=' + this.config.lat + '&lng=' + this.config.lon + '&overname=2&zoom=' + zoom + '&size=2b&voor=' + (this.config.forecast ? '1' : '0');
mapContainer.appendChild(frame);
return mapContainer;
}
});