Skip to content

Commit 2d2dba0

Browse files
committed
Moving non-standard map controls to a separate component
1 parent 9a545ea commit 2d2dba0

File tree

2 files changed

+57
-23
lines changed

2 files changed

+57
-23
lines changed

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

Lines changed: 15 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,6 @@
1010
Control,
1111
ControlButton,
1212
ControlGroup,
13-
NavigationControl,
14-
GeolocateControl,
15-
FullscreenControl,
16-
ScaleControl,
1713
} from "svelte-maplibre";
1814
import { contrastingColor, colorPalette } from "./colors.ts";
1915
import { hoverStateFilter } from "svelte-maplibre/filters.js";
@@ -27,6 +23,7 @@
2723
jenksBreaks,
2824
quantileBreaks,
2925
} from "./mapUtils.js";
26+
import NonStandardControls from "./NonStandardControls.svelte";
3027
3128
let {
3229
data,
@@ -205,26 +202,20 @@
205202
{center}
206203
{zoom}
207204
>
208-
{#if navigationControl && !standardControls}
209-
{#key navigationControlPosition}
210-
<NavigationControl position={navigationControlPosition} />
211-
{/key}
212-
{/if}
213-
{#if geolocateControl && !standardControls}
214-
{#key geolocateControlPosition}
215-
<GeolocateControl position={geolocateControlPosition} />
216-
{/key}
217-
{/if}
218-
{#if fullscreenControl && !standardControls}
219-
{#key fullscreenControlPosition}
220-
<FullscreenControl position={fullscreenControlPosition} />
221-
{/key}
222-
{/if}
223-
{#if scaleControl && !standardControls}
224-
{#key { scaleControlPosition, scaleControlUnit }}
225-
<ScaleControl position={scaleControlPosition} unit={scaleControlUnit} />
226-
{/key}
205+
{#if !standardControls}
206+
<NonStandardControls
207+
{navigationControl}
208+
{navigationControlPosition}
209+
{geolocateControl}
210+
{geolocateControlPosition}
211+
{fullscreenControl}
212+
{fullscreenControlPosition}
213+
{scaleControl}
214+
{scaleControlPosition}
215+
{scaleControlUnit}
216+
/>
227217
{/if}
218+
228219
<Control>
229220
<ControlGroup>
230221
<button
@@ -291,5 +282,6 @@
291282
/* margin: 10px; */
292283
width: fit-content;
293284
padding: 0px 10px;
285+
font-size: 16px;
294286
}
295287
</style>
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<script lang="ts">
2+
//@ts-nocheck
3+
import {
4+
FullscreenControl,
5+
GeolocateControl,
6+
NavigationControl,
7+
ScaleControl,
8+
} from "svelte-maplibre";
9+
10+
let {
11+
navigationControl,
12+
navigationControlPosition = "top-left",
13+
geolocateControl,
14+
geolocateControlPosition = "top-left",
15+
fullscreenControl,
16+
fullscreenControlPosition = "top-left",
17+
scaleControl,
18+
scaleControlPosition = "bottom-left",
19+
scaleControlUnit = "metric",
20+
} = $props();
21+
</script>
22+
23+
{#if navigationControl}
24+
{#key navigationControlPosition}
25+
<NavigationControl position={navigationControlPosition} />
26+
{/key}
27+
{/if}
28+
{#if geolocateControl}
29+
{#key geolocateControlPosition}
30+
<GeolocateControl position={geolocateControlPosition} />
31+
{/key}
32+
{/if}
33+
{#if fullscreenControl}
34+
{#key fullscreenControlPosition}
35+
<FullscreenControl position={fullscreenControlPosition} />
36+
{/key}
37+
{/if}
38+
{#if scaleControl}
39+
{#key { scaleControlPosition, scaleControlUnit }}
40+
<ScaleControl position={scaleControlPosition} unit={scaleControlUnit} />
41+
{/key}
42+
{/if}

0 commit comments

Comments
 (0)