-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
59 lines (47 loc) · 2.54 KB
/
script.js
File metadata and controls
59 lines (47 loc) · 2.54 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
document.addEventListener('DOMContentLoaded', () => {
const map = L.map('map').setView([45, 0], 2); // Centered to see Europe and US
L.tileLayer('https://api.maptiler.com/maps/dataviz/{z}/{x}/{y}.png?key=oZ81FlDBLyb29JHKw9Ia', {
attribution: '<a href="https://www.maptiler.com/copyright/" target="_blank">© MapTiler</a> <a href="https://www.openstreetmap.org/copyright" target="_blank">© OpenStreetMap contributors</a>'
}).addTo(map);
const fabCityIcon = L.icon({
iconUrl: 'https://raw.githubusercontent.com/fabcity/citiesmap/main/citiesdata/fabcitypin.png',
iconSize: [40, 40],
className: 'fab-city-icon'
});
const fabCityIconInactive = L.icon({
iconUrl: 'https://raw.githubusercontent.com/fabcity/citiesmap/main/citiesdata/fabcitypin.png',
iconSize: [40, 40],
className: 'fab-city-icon-inactive'
});
const markers = L.markerClusterGroup();
CITIES_DATA.forEach(city => {
const icon = city.status === 'Active' ? fabCityIcon : fabCityIconInactive;
const marker = L.marker([city.lat, city.lng], { icon: icon });
let popupContent = `<h3>${city.name}</h3>`;
popupContent += `<p><b>Status:</b> ${city.status}</p>`;
popupContent += `<p><b>Population:</b> ${city.population}</p>`;
popupContent += `<p><b>Fab Labs:</b> ${city.fablabs}</p>`;
popupContent += `<p><b>Consortium Partners:</b> ${city.partner1}, ${city.partner2}, ${city.partner3}</p>`;
popupContent += `<p><b>Projects:</b> ${city.projects}</p>`;
popupContent += `<p><b>Funding:</b> ${city.funding}</p>`;
popupContent += `<p><b>CO2 Emissions:</b> ${city.co2}</p>`;
popupContent += `<p><b>Recycling Rate:</b> ${city.recycling}</p>`;
popupContent += `<p><b>Circular Economy Employment:</b> ${city.employment}</p>`;
if (city.url) {
popupContent += `<a href="${city.url}" target="_blank">Website</a>`;
}
marker.bindPopup(popupContent);
markers.addLayer(marker);
});
map.addLayer(markers);
const info = L.control({position: 'bottomright'});
info.onAdd = function (map) {
this._div = L.DomUtil.create('div', 'info-box');
this.update();
return this._div;
};
info.update = function () {
this._div.innerHTML = '<h4>Fab City Network</h4><p>As per August 2026. This map features the network members of the Fab City Global Initiative. Learn more at: <a href="http://www.fab.city" target="_blank">www.fab.city</a></p>';
};
info.addTo(map);
});