-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathleafletmap.js
More file actions
29 lines (25 loc) · 806 Bytes
/
leafletmap.js
File metadata and controls
29 lines (25 loc) · 806 Bytes
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
function adopterData(feature, layer) {
let description = `<b>${feature.properties.institution}</b>`;
if (feature.properties.department) {
description += `<br />${feature.properties.department}`
}
layer.bindPopup(description);
}
window.onload = function () {
const basemap = L.tileLayer('https://a.tile.openstreetmap.org/{z}/{x}/{y}.png', {
attribution: '© <a href="https://osm.org/copyright">OpenStreetMap</a> contributors',
noWrap: false
});
fetch('adopters.geojson')
.then(response => response.json())
.then(data => {
const geojson = L.geoJson(data, {
onEachFeature: adopterData
});
const map = L
.map('map', {minZoom: 2})
.fitBounds(geojson.getBounds());
basemap.addTo(map);
geojson.addTo(map);
});
};