62 lines
2.2 KiB
HTML
62 lines
2.2 KiB
HTML
<!doctype html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<title>Leaflet demo</title>
|
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
|
|
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.3.1/dist/leaflet.css"/>
|
|
<script src="https://unpkg.com/leaflet@1.3.1/dist/leaflet.js"></script>
|
|
|
|
</head>
|
|
<body>
|
|
|
|
<main style="margin-left: 20px;margin-right: 20px;">
|
|
|
|
<div class="row">
|
|
<h3>Speckle pygeoapi demo: fetch comments</h3>
|
|
</div>
|
|
<div>
|
|
<div class="row">
|
|
<div id="items-map" style="min-height: 80vh;"></div>
|
|
</div>
|
|
</div>
|
|
</main>
|
|
|
|
|
|
<script>
|
|
var map = L.map('items-map').setView([ 45 , -75 ], 5);
|
|
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 () => {
|
|
const speckle_data = await fetch('https://geo.speckle.systems/speckle/?speckleUrl=https://app.speckle.systems/projects/344f803f81/models/5582ab673e&datatype=projectcomments', {
|
|
headers: {
|
|
'Accept': 'application/geo+json'
|
|
}
|
|
}).then(response => response.json());
|
|
|
|
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>
|