|
22 | 22 | <body>
|
23 | 23 |
|
24 | 24 | <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%"> |
26 | 26 | </div>
|
27 | 27 | <script type="module">
|
28 | 28 | // import define from "./tree-of-life/index.js";
|
|
62 | 62 | const svg = d3.create("svg")
|
63 | 63 | .attr("viewBox", [-outerRadius, -outerRadius, width, width])
|
64 | 64 | .attr("font-family", "sans-serif")
|
65 |
| - .attr("font-size", 10); |
| 65 | + .attr("font-size", 12); |
66 | 66 |
|
67 | 67 | // Add background circle
|
68 | 68 | svg.append("circle")
|
|
92 | 92 | .attr("fill", "none")
|
93 | 93 | .attr("stroke", "#fff")
|
94 | 94 | .attr("stroke-opacity", 0.25)
|
95 |
| - .attr("stroke-width", 2) |
| 95 | + .attr("stroke-width", 4) |
96 | 96 | .selectAll("path")
|
97 | 97 | .data(root.links().filter(d => !d.target.children))
|
98 | 98 | .join("path")
|
|
160 | 160 |
|
161 | 161 | const layersToUpdate = ['buildings', 'morphotopes', 'h3', 'grid'];
|
162 | 162 | layersToUpdate.forEach(layer => {
|
163 |
| - |
164 | 163 | map.setFilter(layer, ['in', ['get', 'final_without_noise'], ['literal', leafIds]]);
|
165 |
| - |
166 | 164 | });
|
167 | 165 | });
|
168 | 166 |
|
| 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 | + |
169 | 176 | svg.append("g")
|
170 | 177 | .selectAll("text")
|
171 | 178 | .data(root.leaves())
|
|
667 | 674 | map.getCanvas().style.cursor = '';
|
668 | 675 | });
|
669 | 676 |
|
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 |
| - |
698 | 677 | // add layer control
|
699 | 678 | const layers = [
|
700 | 679 | { id: 'buildings', name: 'Buildings' },
|
701 | 680 | { id: 'morphotopes', name: 'Morphotopes' },
|
702 |
| - { id: 'h3', name: 'H3' }, |
| 681 | + { id: 'h3', name: 'H3 level 10' }, |
703 | 682 | { id: 'grid', name: 'Grid 250m' },
|
704 |
| - { id: 'regions', name: 'Regions' } |
705 | 683 | ];
|
706 | 684 |
|
707 | 685 | const layerControl = document.createElement('div');
|
|
710 | 688 | layerControl.style.top = '10px';
|
711 | 689 | layerControl.style.right = '10px';
|
712 | 690 | 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'; |
713 | 694 | layerControl.style.padding = '10px';
|
714 | 695 | layerControl.style.borderRadius = '5px';
|
715 | 696 | layerControl.style.boxShadow = '0 0 10px rgba(0,0,0,0.5)';
|
|
751 | 732 | let nav = new maplibregl.NavigationControl();
|
752 | 733 | map.addControl(nav, 'top-left');
|
753 | 734 |
|
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 | + // }); |
768 | 750 |
|
769 | 751 | </script>
|
770 | 752 | </body>
|
|
0 commit comments