-
Notifications
You must be signed in to change notification settings - Fork 12
/
analysis.html
145 lines (108 loc) · 3.5 KB
/
analysis.html
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Visitationszone</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="">
<!-- Le styles -->
<link href="css/bootstrap.min.css" rel="stylesheet">
<link href="css/cosmo.bootstrap.min.css" rel="stylesheet">
<style type="text/css">
body {
padding: 60px;
}
#map { height: 800px; margin-bottom: 20px;}
sup { cursor: help;}
</style>
<link rel="stylesheet" href="css/leaflet.css" />
<link rel="stylesheet" href="css/leaflet.draw.css" />
<link rel="stylesheet" href="css/datepicker.css" />
</head>
<body>
<div class="container">
<section id="themap">
<div id="map"></div>
</section>
</div>
<script src="js/jquery.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<script src="js/leaflet.js"></script>
<script src="js/leaflet.draw.js"></script>
<script src="js/datepicker.js"></script>
<script type="text/javascript">
function getDate(str){
var strparts = str.split(" ");
var dateparts = strparts[0].split("-");
var timeparts = strparts[1].split(":");
var date = new Date(parseInt(dateparts[0]), parseInt(dateparts[1]-1), parseInt(dateparts[2]), parseInt(timeparts[0]), parseInt(timeparts[1]));
return date;
}
var map = L.map('map').setView([56, 10], 7);
var attribution = "Data from OpenStreetMap";
var drawControl = new L.Control.Draw({
draw:{
position: 'topleft',
polyline: false,
circle: false,
rectangle: false,
marker: false,
polygon: {
allowIntersection: false,
shapeOptions: {
"color": "#F50F43",
"weight": 2,
"opacity": 0.7
}
}
}
});
var poly = null;
var kredsStyle = {
"color": "#0000ff",
"weight": 2,
"opacity": 1,
"fillOpacity": 0
};
var activeStyle = {
"color": "#ff0000",
"weight": 0,
"fillOpacity": 0.4,
"dashArray": null
};
var pastStyle = {
"color": "#ffffff",
"weight": 1,
"opacity": 0,
"fillOpacity": 0.05,
"dashArray": null
};
$(function(){
L.tileLayer('https://a.tile.openstreetmap.org/{z}/{x}/{y}.png', {attribution: attribution}).addTo(map);
$.getJSON("/oio/kommuner.geojson", function(geojson){
var obj = L.geoJson(geojson, {style: kredsStyle});
obj.addTo(map);
});
$.getJSON("/zones.json?" + Date.now(), function(data){
var today = new Date();
for(var id = 0; id < data.features.length; id++){
var expire = getDate(data.features[id].properties.end);
var style = pastStyle;
if(expire > today) {
style = activeStyle;
}
data.features[id].properties.id = id;
data.features[id].properties.style = style;
}
var obj = L.geoJson(data, {
onEachFeature: function (feature, layer) {
layer.setStyle(feature.properties.style);
}
});
obj.addTo(map);
});
});
</script>
</body>
</html>