Skip to content

Commit 458abc3

Browse files
committed
Disable other layers when streetview is enabled. #359
1 parent a965c5b commit 458abc3

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

src/lib/browse/LayerControls.svelte

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
StreetViewTool,
88
} from "lib/common";
99
import { CheckboxGroup } from "lib/govuk";
10+
import { layerId } from "lib/maplibre";
11+
import { FillLayer, GeoJSON } from "svelte-maplibre";
1012
import CensusOutputAreaLayerControl from "./layers/areas/CensusOutputAreas.svelte";
1113
import CombinedAuthoritiesLayerControl from "./layers/areas/CombinedAuthorities.svelte";
1214
import ImdLayerControl from "./layers/areas/IMD.svelte";
@@ -35,6 +37,26 @@
3537
// Workaround for https://github.com/sveltejs/svelte/issues/7630
3638
$: streetviewEnabled = !$interactiveMapLayersEnabled;
3739
$: interactiveMapLayersEnabled.set(!streetviewEnabled);
40+
41+
// When StreetView is on, disable interactive layers -- no hovering or
42+
// clicking behavior. Achieve this by enabling an invisible layer on top of
43+
// everything.
44+
let coverEverything = {
45+
type: "Feature" as const,
46+
properties: {},
47+
geometry: {
48+
type: "Polygon" as const,
49+
coordinates: [
50+
[
51+
[180.0, 90.0],
52+
[-180.0, 90.0],
53+
[-180.0, -90.0],
54+
[180.0, -90.0],
55+
[180.0, 90.0],
56+
],
57+
],
58+
},
59+
};
3860
</script>
3961

4062
<CollapsibleCard label="Layers" open>
@@ -89,3 +111,16 @@
89111
</CollapsibleCard>
90112
<BaselayerSwitcher disabled={!$interactiveMapLayersEnabled} />
91113
</CollapsibleCard>
114+
115+
<GeoJSON data={coverEverything}>
116+
<FillLayer
117+
{...layerId("cover-interactive-layers")}
118+
paint={{
119+
"fill-color": "black",
120+
"fill-opacity": 0.0,
121+
}}
122+
layout={{
123+
visibility: $interactiveMapLayersEnabled ? "none" : "visible",
124+
}}
125+
/>
126+
</GeoJSON>

src/lib/maplibre/zorder.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,4 +137,6 @@ const layerZorder = [
137137

138138
// TODO This might look nicer lower
139139
"georeferenced-image",
140+
141+
"cover-interactive-layers",
140142
];

0 commit comments

Comments
 (0)