-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmappa.html
236 lines (198 loc) · 8.41 KB
/
mappa.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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>I 30 chilometri di spostamenti del decreto di Natale</title>
<link rel='shortcut icon' type='image/x-icon' href='/images/favicon.ico' />
<link rel="apple-touch-icon" sizes="180x180" href="images/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="32x32" href="images/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="images/favicon-16x16.png">
<link rel="manifest" href="/images/site.webmanifest">
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<link rel="stylesheet" href="https://unpkg.com/[email protected]/dist/leaflet.css" />
<script src="https://unpkg.com/[email protected]/dist/leaflet.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/proj4js/2.5.0/proj4.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/proj4leaflet/1.0.2/proj4leaflet.js"></script>
<!-- Dependency to Leaflet Draw -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/leaflet.draw/0.3.2/leaflet.draw.css" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/leaflet.draw/0.3.2/leaflet.draw.js"></script>
<link rel="stylesheet" href="css/leaflet.measurecontrol.css" />
<script src="js/leaflet.measurecontrol.js"></script>
<style>
body {
margin: 0;
padding: 0;
}
#map {
position: absolute;
top: 0;
bottom: 0;
width: 100%;
}
#homeButton {
color: #ff7800;
position: absolute;
top: 10px;
right: 50%;
padding: 5px;
z-index: 400000;
font-weight: bold;
border-radius: 4px;
background-color: white;
border: 1px solid;
}
</style>
<link rel="stylesheet" href="./js/Control.MiniMap.css" />
<script src="./js/Control.MiniMap.js" type="text/javascript"></script>
<meta property="og:title" content="I 30 chilometri di spostamenti del decreto di Natale" />
<meta property="og:description"
content="Per avere un quadro sul contesto numerico e geografico di questa parte del decreto" />
<meta property="og:url" content="https://ondata.github.io/30cappa" />
<meta property="og:type" content="article" />
<meta property="article:tag" content="dati" />
<meta property="article:tag" content="covid" />
<meta property="article:tag" content="covid-19" />
<meta property="og:image" content="https://i.imgur.com/CxiskOb.png" />
<meta property="og:site_name" content="30cappa" />
<!-- twitter -->
<meta name="twitter:card" content="summary_large_image" />
<meta name="twitter:title" content="I 30 chilometri di spostamenti del decreto di Natale">
<meta name="twitter:description"
content="Per avere un quadro sul contesto numerico e geografico di questa parte del decreto">
<meta name="twitter:image" content="https://i.imgur.com/CxiskOb.png">
<meta name="twitter:site" content="30cappa" />
<meta name="twitter:url" content="https://ondata.github.io/30cappa">
</head>
<body>
<script src='js/leaflet-hash.js'></script>
<div id='map'>
<button onclick="location.href='https://ondata.github.io/30cappa';" id="homeButton">Home</button>
</div>
<script>
const map =
L.map('map', {
minZoom: 5,
maxZoom: 17
})
.setView([38.1089, 13.3545], 18);
function getURLParameter(name) {
return decodeURIComponent((new RegExp('[?|&]' + name + '=' + '([^&;]+?)(&|#|;|$)').exec(location.search) || [null, ''])[1].replace(/\+/g, '%20')) || null;
};
const myvar = getURLParameter('id');
function onEachFeature(feature, layer) {
layer.bindPopup()
layer.on('click', (a) => {
layer.bindPopup('In <span style="color:#ff7800">arancione</span>, l\'area in cui sono consentiti spostamenti, nei giorni <b>28, 29, 30 dicembre 2020</b> e <b>4 gennaio 2021</b>, per i residenti nel comune di <b><span style="color:#FF0000">' + feature.properties.COMUNE + '</span></b> (<a href="https://www.gazzettaufficiale.it/eli/id/2020/12/18/20G00196/s" target="_blank">decreto legge 172</a>)')
});
}
const googleHybrid = L.tileLayer('http://{s}.google.com/vt/lyrs=s,h&x={x}&y={y}&z={z}', {
maxZoom: 20,
subdomains: ['mt0', 'mt1', 'mt2', 'mt3'],
attribution: '<a href="https://www.google.com/maps/">Google</a>'
});
const opens = L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
maxZoom: 19,
attribution: '© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
});
//opens.addTo(map);
var topografica = L.tileLayer('https://stamen-tiles-{s}.a.ssl.fastly.net/terrain/{z}/{x}/{y}.png', {
maxZoom: 13,
attribution: 'Layer topografici <a target="_blank" href="https://stamen.com/">Stamen Design</a> e © <a target="_blank" href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
});
topografica.addTo(map);
map.on("zoomend", function (e) {
console.log("Zoom level: ", map.getZoom());
if (map.getZoom() > 13) { //Level 13 is the treshold
var topografica = L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
maxZoom: 19
});
map.removeLayer(topografica);
topografica.addTo(map);
} else {
var topografica = L.tileLayer('https://stamen-tiles-{s}.a.ssl.fastly.net/terrain/{z}/{x}/{y}.png', {
maxZoom: 13
});
map.removeLayer(topografica);
topografica.addTo(map);
}
});
const limite = $.ajax({
url: "https://ondata.github.io/30cappa/dati/arigadicomando/output_noreg/" + myvar + ".geojson",
dataType: "json",
success: console.log("geometria caricata."),
error(xhr) {
alert("Codice comune non trovato o numero di abitanti superiore a 5000")
}
})
$.when(limite).done(() => {
const myStyle = {
"color": "#ff7800",
"weight": 1,
"opacity": 1,
"fill": true,
"fillOpacity": 0.25
};
const layerLimite = L.geoJSON(limite.responseJSON, {
style: myStyle,
onEachFeature: onEachFeature
}).addTo(map);
// zoomma ai limiti del buffer di 30 km soltanto se è un indirizzo senza hash
if (document.location.href.indexOf('#') === -1) {
map.fitBounds(layerLimite.getBounds());
}
});
const limiteC = $.ajax({
url: "https://tanto.carto.com:443/api/v2/sql?format=GeoJSON&q=select%20*%20from%20public.comuni_4326%20where%20public.comuni_4326.istat%3D%27" + myvar + "%27",
dataType: "json",
success: console.log("geometria caricata."),
error(xhr) {
alert(xhr.statusText)
}
})
$.when(limiteC).done(() => {
const myStyleC = {
"color": "#FF0000",
"weight": 2,
"opacity": 1,
"fill": false,
"fillOpacity": 0
};
const layerLimiteC = L.geoJSON(limiteC.responseJSON, {
style: myStyleC
}).addTo(map);
});
const osmUrl = 'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png';
const osmAttrib = 'Map data © OpenStreetMap contributors';
const osm = new L.TileLayer(osmUrl, { minZoom: 0, maxZoom: 8, attribution: osmAttrib });
const miniMap = new L.Control.MiniMap(osm, { toggleDisplay: true }).addTo(map);
var baseMaps = {
"Topografica": topografica, // googleStreets,
"Google Maps Hybrid": googleHybrid
};
L.control.layers(baseMaps).addTo(map);
L.control.scale().addTo(map);
L.Control.measureControl().addTo(map);
// carica hash plugin dopo il caricamento della pagina
window.addEventListener("load", function () {
var hash = new L.Hash(map);
});
</script>
<!-- Matomo -->
<script type="text/javascript">
var _paq = window._paq = window._paq || [];
/* tracker methods like "setCustomDimension" should be called before "trackPageView" */
_paq.push(['trackPageView']);
_paq.push(['enableLinkTracking']);
(function() {
var u="//stats.labmod.org/";
_paq.push(['setTrackerUrl', u+'matomo.php']);
_paq.push(['setSiteId', '8']);
var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
g.type='text/javascript'; g.async=true; g.src=u+'matomo.js'; s.parentNode.insertBefore(g,s);
})();
</script>
<noscript><p><img src="//stats.labmod.org/matomo.php?idsite=8&rec=1" style="border:0;" alt="" /></p></noscript>
<!-- End Matomo Code -->
</body>
</html>