-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplayground2.html
More file actions
34 lines (23 loc) · 767 Bytes
/
playground2.html
File metadata and controls
34 lines (23 loc) · 767 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
30
31
32
33
34
<link rel="stylesheet" href="includes/leaflet.css" />
<script src="includes/leaflet.js"></script>
<script src="includes/turf"></script>
<body onload="initialize()">
<div id="map" style="height: 600px;"></div>
<script>
function initialize(){
//Create a Leaflet map and set the view to the center of the polygon
const map = L.map('map').setView([37.8, -96], 4);
// Add a tile layer to the map
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png').addTo(map);
fetch('usa.geojson')
.then(response => response.json())
.then(geojson => {
L.geoJSON(geojson).addTo(map);
const buff = turf.buffer(geojson, 25, { units: 'miles' });
L.geoJSON(buff).addTo(map);
}
);
}
</script>
</body>
``