-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
55 lines (53 loc) · 1.68 KB
/
index.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
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="https://unpkg.com/[email protected]/dist/leaflet.css"
integrity="sha256-p4NxAoJBhIIN+hmNHrzRCf9tD/miZyoHS5obTRR9BMY="
crossorigin=""/>
<!-- Make sure you put this AFTER Leaflet's CSS -->
<script src="https://unpkg.com/[email protected]/dist/leaflet.js"
integrity="sha256-20nQCchB9co0qIjJZRGuk2/Z9VM+kNiyxNV1lvTlZBo="
crossorigin=""></script>
<style>
#map {
bottom: 0;
left: 0;
position: absolute;
right: 0;
top: 0;
}
</style>
</head>
<body>
<div id="map" style="background: rgb(187, 212, 220)"></div>
<script type="module">
var map = L.map('map', {
maxBounds: [[-90,-180],[90,180]],
maxBoundsViscosity: 1
}).setView([0, 0], 3);
map.setMinZoom(2);
const response = await fetch("./data/herp-countries.geojson");
const geojson = await response.json();
const lyr = L.geoJSON(geojson, {
onEachFeature: (feat, lyr) => {
console.log(feat.properties.orgs)
if (feat.properties.orgs) {
const color = feat.properties.color ;
lyr.bindPopup(`
<h1>${feat.properties.SOVEREIGNT}</h1>
${feat.properties.orgs.map(org => org.comm_name).sort().join("<br/>")}
`)
}
},
style: feat => {
if (feat.properties.orgs) {
return { color: "#EEE", fillColor: "#1471b0", fillOpacity: 1, weight: 1 };
} else {
return { color: "#EEE", fillColor: " rgb(11, 11, 29)", fillOpacity: 1, weight: 1 };
}
}
});
lyr.addTo(map);
</script>
</body>
</html>