-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
100 lines (83 loc) · 3.46 KB
/
index.html
File metadata and controls
100 lines (83 loc) · 3.46 KB
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
<html>
<head>
<title>Syracuse snowplow tracking map</title>
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.4.0/dist/leaflet.css"
integrity="sha512-puBpdR0798OZvTTbP4A8Ix/l+A4dHDD0DGqYW6RQ+9jxkRFclaxxQb/SJAWZfWAkuyeQUytO7+7N4QKrDh+drA=="
crossorigin=""/>
<script src="https://unpkg.com/leaflet@1.4.0/dist/leaflet.js"
integrity="sha512-QVftwZFqvtRNi0ZyCtsznlKSWOStnDORoefr1enyq5mVL4tmKB3S/EnC3rRJcxCPavG10IcrVGSmPh6Qw5lwrg=="
crossorigin=""></script>
<script src="https://code.jquery.com/jquery-2.1.1.min.js"></script>
<style>
#map{ height: 100% }
</style>
</head>
<body>
<div id="map"></div>
<script>
// initialize the map
var map = L.map('map').setView([43.047939,-76.147453], 13);
var plowed = L.layerGroup();
var notplowed = L.layerGroup();
var plowedlasthour = L.layerGroup();
var d = new Date();
var lasthourd = new Date; lasthourd.setHours( lasthourd.getHours() - 1);
var lasthour = lasthourd.getHours();
var year = d.getFullYear()
var month = ("0" + (d.getMonth() +1)).slice(-2)
var day = ("0" + d.getDate()).slice(-2)
var ymd = year + "-" + month + "-" + day
// load a tile layer
L.tileLayer('https://{s}.basemaps.cartocdn.com/light_all/{z}/{x}/{y}{r}.png', {
attribution: '© <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a> © <a href="https://carto.com/attributions">CARTO</a>',
subdomains: 'abcd',
maxZoom: 19
}).addTo(map);
$.getJSON("mergeddata.geojson", function(plowedlasthourdata){
L.geoJson(plowedlasthourdata, {
filter: function(feature, layer) {
return (feature.properties.hour == lasthour) & (feature.properties.date == ymd);
},
style: function(feature){
return { color: "green", weight: 1, fillColor: 'green', fillOpacity: .5, Opacity: 1 };
},
onEachFeature: function( feature, layer ){
layer.bindPopup( "<strong>" + feature.properties.STREET + "</strong><br/>" + "Street last plowed at: " + feature.properties.hour + ":00 on " + feature.properties.date)
}
}).addTo(plowedlasthour);
});
$.getJSON("notplowed.geojson",function(notploweddata){
L.geoJson( notploweddata, {
style: function(feature){
return { color: "grey", weight: .1, fillColor: "grey", fillOpacity: .5 };
},
onEachFeature: function( feature, layer ){
layer.bindPopup( "<strong>" + feature.properties.STREET + "</strong><br/>" + "Not plowed yet")
}
}).addTo(notplowed);
});
$.getJSON("mergeddata.geojson", function(ploweddata){
L.geoJson(ploweddata, {
filter: function(feature, layer) {
return feature.properties.hour != lasthour;
},
style: function(feature){
return { color: "green", weight: .2, fillColor: 'green', fillOpacity: .2, Opacity:.2 };
},
onEachFeature: function( feature, layer ){
layer.bindPopup( "<strong>" + feature.properties.STREET + "</strong><br/>" + "Street last plowed at: " + feature.properties.hour + ":00 on " + feature.properties.date)
}
}).addTo(plowed);
});
plowedlasthour.addTo(map);
notplowed.addTo(map);
plowed.addTo(map);
var overlays = {
"Plowed Last Hour": plowedlasthour,
"Plowed": plowed,
"Not yet plowed": notplowed
};
L.control.layers(null, overlays,{collapsed:false, position: 'bottomright'}).addTo(map);
</script>
</body>
</html>