Skip to content

Commit 3c26fbc

Browse files
committed
disable filter, style
1 parent 75e68bc commit 3c26fbc

File tree

1 file changed

+31
-49
lines changed

1 file changed

+31
-49
lines changed

index.html

Lines changed: 31 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
<body>
2323

2424
<div id="tree-of-life-output"
25-
style="position: absolute; bottom: 50px; right: 20px; padding: 10px; border-radius: 5px; box-shadow: 0 0 10px rgba(0,0,0,0.5); z-index: 1; min-width: 400px; max-width: 25%">
25+
style="position: absolute; bottom: 50px; right: 0px; padding: 0px; z-index: 1; min-width: 400px; max-width: 25%">
2626
</div>
2727
<script type="module">
2828
// import define from "./tree-of-life/index.js";
@@ -62,7 +62,7 @@
6262
const svg = d3.create("svg")
6363
.attr("viewBox", [-outerRadius, -outerRadius, width, width])
6464
.attr("font-family", "sans-serif")
65-
.attr("font-size", 10);
65+
.attr("font-size", 12);
6666

6767
// Add background circle
6868
svg.append("circle")
@@ -92,7 +92,7 @@
9292
.attr("fill", "none")
9393
.attr("stroke", "#fff")
9494
.attr("stroke-opacity", 0.25)
95-
.attr("stroke-width", 2)
95+
.attr("stroke-width", 4)
9696
.selectAll("path")
9797
.data(root.links().filter(d => !d.target.children))
9898
.join("path")
@@ -160,12 +160,19 @@
160160

161161
const layersToUpdate = ['buildings', 'morphotopes', 'h3', 'grid'];
162162
layersToUpdate.forEach(layer => {
163-
164163
map.setFilter(layer, ['in', ['get', 'final_without_noise'], ['literal', leafIds]]);
165-
166164
});
167165
});
168166

167+
svg.on("click", function (event) {
168+
if (event.target.tagName !== 'path') {
169+
const layersToUpdate = ['buildings', 'morphotopes', 'h3', 'grid'];
170+
layersToUpdate.forEach(layer => {
171+
map.setFilter(layer, null);
172+
});
173+
}
174+
});
175+
169176
svg.append("g")
170177
.selectAll("text")
171178
.data(root.leaves())
@@ -667,41 +674,12 @@
667674
map.getCanvas().style.cursor = '';
668675
});
669676

670-
// add regions hulls for debugging purposes
671-
map.addSource('geojson-source', {
672-
type: 'geojson',
673-
// data: 'http://127.0.0.1:8000/regions.geojson' // use this when developing locally
674-
data: 'https://uscuni.org/himoc/regions.geojson'
675-
});
676-
677-
map.addLayer({
678-
id: 'regions',
679-
type: 'line',
680-
source: 'geojson-source',
681-
'layout': {
682-
'visibility': 'none'
683-
},
684-
paint: {
685-
'line-color': '#ffffff',
686-
'line-width': 2,
687-
'line-dasharray': [2, 2]
688-
}
689-
});
690-
691-
map.on('click', 'regions', function (e) {
692-
new maplibregl.Popup()
693-
.setLngLat(e.lngLat)
694-
.setHTML(e.features[0].properties.labels)
695-
.addTo(map);
696-
});
697-
698677
// add layer control
699678
const layers = [
700679
{ id: 'buildings', name: 'Buildings' },
701680
{ id: 'morphotopes', name: 'Morphotopes' },
702-
{ id: 'h3', name: 'H3' },
681+
{ id: 'h3', name: 'H3 level 10' },
703682
{ id: 'grid', name: 'Grid 250m' },
704-
{ id: 'regions', name: 'Regions' }
705683
];
706684

707685
const layerControl = document.createElement('div');
@@ -710,6 +688,9 @@
710688
layerControl.style.top = '10px';
711689
layerControl.style.right = '10px';
712690
layerControl.style.backgroundColor = 'white';
691+
layerControl.style.opacity = 0.8;
692+
layerControl.style.fontFamily = '"Helvetica Neue", Arial, Helvetica, sans-serif';
693+
layerControl.style.fontSize = '12px';
713694
layerControl.style.padding = '10px';
714695
layerControl.style.borderRadius = '5px';
715696
layerControl.style.boxShadow = '0 0 10px rgba(0,0,0,0.5)';
@@ -751,20 +732,21 @@
751732
let nav = new maplibregl.NavigationControl();
752733
map.addControl(nav, 'top-left');
753734

754-
const zoomLevel = document.createElement('div');
755-
zoomLevel.id = 'zoom-level';
756-
zoomLevel.style.position = 'absolute';
757-
zoomLevel.style.bottom = '10px';
758-
zoomLevel.style.left = '10px';
759-
zoomLevel.style.backgroundColor = 'white';
760-
zoomLevel.style.padding = '5px';
761-
zoomLevel.style.borderRadius = '5px';
762-
zoomLevel.style.boxShadow = '0 0 10px rgba(0,0,0,0.5)';
763-
document.body.appendChild(zoomLevel);
764-
765-
map.on('zoom', () => {
766-
zoomLevel.textContent = 'Zoom level: ' + map.getZoom().toFixed(2);
767-
});
735+
// include zoom level indicator
736+
// const zoomLevel = document.createElement('div');
737+
// zoomLevel.id = 'zoom-level';
738+
// zoomLevel.style.position = 'absolute';
739+
// zoomLevel.style.bottom = '10px';
740+
// zoomLevel.style.left = '10px';
741+
// zoomLevel.style.backgroundColor = 'white';
742+
// zoomLevel.style.padding = '5px';
743+
// zoomLevel.style.borderRadius = '5px';
744+
// zoomLevel.style.boxShadow = '0 0 10px rgba(0,0,0,0.5)';
745+
// document.body.appendChild(zoomLevel);
746+
747+
// map.on('zoom', () => {
748+
// zoomLevel.textContent = 'Zoom level: ' + map.getZoom().toFixed(2);
749+
// });
768750

769751
</script>
770752
</body>

0 commit comments

Comments
 (0)