Skip to content

Commit 08bd15a

Browse files
committed
Update Map.svelte
1 parent 5d3a0c2 commit 08bd15a

File tree

1 file changed

+39
-3
lines changed

1 file changed

+39
-3
lines changed

src/lib/components/data-vis/map/Map.svelte

Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -198,8 +198,6 @@
198198
areaToColorLookup?: object;
199199
} = $props();
200200
201-
$inspect(clickedArea);
202-
203201
// ISO-3166/ONS-style prefixes for area codes
204202
const areaCodePrefixes: Record<string, string[]> = {
205203
england: ["E"], // all area codes starting with E
@@ -409,9 +407,12 @@
409407
);
410408
411409
let hoveredArea = $state();
410+
let hoveredAreaArray = $derived(hoveredArea ? [hoveredArea] : []);
412411
let hoveredAreaData = $state();
413412
let currentMousePosition = $state();
414413
414+
$inspect(clickedArea, hoveredAreaArray);
415+
415416
function convertToLngLatBounds(coords: LngLatBoundsLike): LngLatBoundsLike {
416417
const bounds = new LngLatBounds(coords[0], coords[0]);
417418
@@ -587,7 +588,7 @@
587588
);
588589
</script>
589590

590-
<div style="position: relative; height: {mapHeight}px; width: 100%;">
591+
<div style="height: {mapHeight}; width: 100%">
591592
<MapLibre
592593
bind:map
593594
bind:loaded
@@ -758,6 +759,41 @@
758759
sourceLayer={vectorLayerName}
759760
manageHoverState={interactive}
760761
/>
762+
{#if hoveredArea}
763+
<LineLayer
764+
layout={{ "line-cap": "round", "line-join": "round" }}
765+
paint={{ "line-width": 5, "line-color": "orange" }}
766+
beforeLayerType="symbol"
767+
sourceLayer={vectorLayerName}
768+
manageHoverState={interactive}
769+
filter={hoveredArea
770+
? ["==", ["get", promoteProperty], hoveredArea]
771+
: undefined}
772+
/>
773+
{/if}
774+
<!-- <LineLayer
775+
layout={{ "line-cap": "round", "line-join": "round" }}
776+
paint={paintObject}
777+
beforeLayerType="symbol"
778+
sourceLayer={vectorLayerName}
779+
manageHoverState={interactive}
780+
/> -->
781+
<!-- <LineLayer
782+
layout={{ "line-cap": "round", "line-join": "round" }}
783+
paint={paintObject}
784+
beforeLayerType="symbol"
785+
sourceLayer={vectorLayerName}
786+
manageHoverState={interactive}
787+
filter={["==", ["get", "id"], clickedArea]}
788+
/> -->
789+
<!-- <LineLayer
790+
layout={{ "line-cap": "round", "line-join": "round" }}
791+
paint={{ "line-color": "red", "line-width": 10 }}
792+
beforeLayerType="symbol"
793+
sourceLayer={vectorLayerName}
794+
manageHoverState={interactive}
795+
filter={["==", ["get", "id"], hoveredAreaArray]}
796+
/> -->
761797
{/if}
762798
</VectorTileSource>
763799
{:else}

0 commit comments

Comments
 (0)