-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdemo_leaflet_comments.html
58 lines (49 loc) · 2.06 KB
/
demo_leaflet_comments.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
<!DOCTYPE html>
<html>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>SpeckleCon2024 GIS demo</title>
<style type="text/css">
html,body{margin:0px;height:100%;width:100%}
.container{width:100%;height:100%}
</style>
<link rel="stylesheet" href="https://unpkg.com/[email protected]/dist/leaflet.css"/>
<script src="https://unpkg.com/[email protected]/dist/leaflet.js"></script>
<body>
<div id="mapContainer" style="min-height: 80vh;"></div>
<script>
// Add a map object
var map = L.map('mapContainer').setView([ 45 , -75 ], 5);
// Add basemap layer
map.addLayer(new L.TileLayer(
'https://tile.openstreetmap.org/{z}/{x}/{y}.png', {
maxZoom: 22,
attribution: '© <a href="https://openstreetmap.org/copyright">OpenStreetMap contributors</a> © Data: <a href="https://speckle.systems/">Speckle Systems</a>'
}
));
(async () => {
var speckleUrl = 'https://geo.speckle.systems/speckle/?speckleUrl=https://app.speckle.systems/projects/344f803f81/models/5582ab673e&datatype=projectcomments'
const speckle_data = await fetch(speckleUrl, {
headers: {
'Accept': 'application/geo+json'
}
}).then(response => response.json());
console.log(speckle_data)
speckle_layer = L.geoJSON(speckle_data, {
filter: (feature) => {
return feature.displayProperties["object_type"] == "comment"
},
pointToLayer: (feature, latlng) => {
return new L.marker(latlng)
},
onEachFeature: function (feature, layer) {
var html = '<span><td><p>' + feature['properties']['text_html'] + '</p></td> </span>';
layer.bindPopup(html);
}
});
speckle_layer.addTo(map);
map.fitBounds(speckle_layer.getBounds())
})();
</script>
</body>
</html>