-
Notifications
You must be signed in to change notification settings - Fork 0
/
municipios.html
99 lines (91 loc) · 3.95 KB
/
municipios.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv='cache-control' content='no-cache'>
<meta http-equiv='expires' content='0'>
<meta http-equiv='pragma' content='no-cache'>
<title>Elecciones Generales 2023 - La Vanguardia</title>
<script src="https://api.mapbox.com/mapbox-gl-js/v2.9.1/mapbox-gl.js"></script>
<link href="https://api.mapbox.com/mapbox-gl-js/v2.9.1/mapbox-gl.css" rel="stylesheet" type="text/css"/>
<script src="https://api.mapbox.com/mapbox-gl-js/plugins/mapbox-gl-geocoder/v2.3.0/mapbox-gl-geocoder.min.js"></script>
<link href="https://api.mapbox.com/mapbox-gl-js/plugins/mapbox-gl-geocoder/v2.3.0/mapbox-gl-geocoder.css" rel="stylesheet" type="text/css"/>
<link href="./styles.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<div class="map-wrapper">
<div id="map-container"></div>
<!-- map controls -->
<div id="custom-controls" class="map-overflow map-controls hidden">
<div class="map-overflow-wrap">
<div class="map-controls-hint">Selecciona un mapa:</div>
<div class="map-controls-years">
<button class="map-control map-control--year js-year is-active" data-year="2023">2023</button>
<button class="map-control map-control--year js-year" data-year="2019">2019</button>
</div>
<div class="map-controls-fill">
<button class="map-control map-control--fill js-control is-active" data-fill="winner">Ganador</button>
<button class="map-control map-control--fill js-control" data-fill="pp">PP</button>
<button class="map-control map-control--fill js-control" data-fill="psoe">PSOE</button>
<button class="map-control map-control--fill js-control" data-fill="sumar">Sumar</button>
<button class="map-control map-control--fill js-control" data-fill="vox">Vox</button>
<button class="map-control map-control--fill js-control" data-fill="bloques">Bloques</button>
</div>
</div>
</div>
<!-- end map controls -->
<!-- map zoom out -->
<div id="custom-buttons" class="map-overflow map-buttons hidden">
<button id="zoom-out" class="zoom-out" title="Zoom out">
<img src="img/spain.svg" alt="Zoom out">
</button>
</div>
<!-- end map zoom out -->
<!-- legend -->
<div id="legends" class="map-legends hidden">
<div class="map-legends-wrap">
<header id="legends-head" class="map-legends-header"></header>
<div id="legends-body" class="map-legends-body"></div>
</div>
</div>
<!-- end legend -->
</div>
<script src="./map.js"></script>
<script src="./partyColors.js"></script>
<script>
let mapLoaded = false;
mapboxgl.clearStorage();
const loadMap = () => {
const isMobile = window.innerWidth < 900;
const map = new ElectionMap('pk.eyJ1IjoibGF1cjA1IiwiYSI6ImNpbmtmM2FjazAwODF2eG0yNjhteTcxdHIifQ.l7uzjVe2b1L8dHh_Z9JjoQ', {
container: 'map-container',
style: 'mapbox://styles/laur05/cli3c8vra00kw01qu7qf5d8v7?fresh=true',
source: 'mapbox://laur05.elections20230723_adm4?fresh=true',
sourceLayer: 'elections20230723_adm4',
center: [-3.69, 39.89],
zoom: isMobile ? 4.5 : 5,
minZoom: isMobile ? 4.5 : 5,
initialSelect: 'winner2023',
hash: false,
scrollZoom: false,
partyColors: window._partyColors,
});
mapLoaded = true;
}
// Remove Mapbox service worker cache
if (caches && caches.keys()) {
caches.keys().then((keys) => {
Promise.all(keys.filter((k) => k === 'mapbox-tiles').map((k) => caches.delete(k)))
.then(() => { loadMap() })
.catch(() => { loadMap() });
})
} else loadMap();
// Fallback if map has not been loaded
setTimeout(() => {
if (!mapLoaded) loadMap();
}, 4000);
</script>
</body>
</html>