@classic-homes/maps-svelte 0.9.0 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +40 -22
- package/dist/lib/components/base/MapError.svelte +69 -14
- package/dist/lib/components/base/MapError.svelte.d.ts +13 -0
- package/dist/lib/components/controls/FitBoundsControl.svelte +98 -0
- package/dist/lib/components/controls/FitBoundsControl.svelte.d.ts +29 -0
- package/dist/lib/components/controls/index.d.ts +1 -0
- package/dist/lib/components/controls/index.js +1 -0
- package/dist/lib/components/core/Map.svelte +29 -0
- package/dist/lib/components/index.d.ts +1 -1
- package/dist/lib/components/index.js +1 -1
- package/dist/lib/index.d.ts +2 -2
- package/dist/lib/index.js +2 -2
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -45,11 +45,7 @@ MapLibre 5 bundles its worker and needs none of this.
|
|
|
45
45
|
</script>
|
|
46
46
|
|
|
47
47
|
<MapContainer class="h-[500px]">
|
|
48
|
-
<Map
|
|
49
|
-
initialCenter={[-122.4, 37.8]}
|
|
50
|
-
initialZoom={12}
|
|
51
|
-
onClick={(e) => console.log('Clicked:', e.lngLat)}
|
|
52
|
-
>
|
|
48
|
+
<Map center={[-122.4, 37.8]} zoom={12} onClick={(e) => console.log('Clicked:', e.lngLat)}>
|
|
53
49
|
<Source id="lots" data={geojsonData}>
|
|
54
50
|
<FillLayer id="lots-fill" fillColor="#22c55e" fillOpacity={0.7} />
|
|
55
51
|
</Source>
|
|
@@ -97,23 +93,23 @@ MapLibre 5 bundles its worker and needs none of this.
|
|
|
97
93
|
</script>
|
|
98
94
|
|
|
99
95
|
<Map
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
96
|
+
center={[-122.4, 37.8]}
|
|
97
|
+
zoom={12}
|
|
98
|
+
bearing={0}
|
|
99
|
+
pitch={0}
|
|
104
100
|
{bounds}
|
|
105
|
-
|
|
101
|
+
boundsPadding={50}
|
|
106
102
|
style={lightBasicStyle}
|
|
107
103
|
theme="light"
|
|
108
104
|
interactive={true}
|
|
109
105
|
scrollZoom={true}
|
|
110
106
|
dragPan={true}
|
|
111
107
|
onClick={handleClick}
|
|
112
|
-
|
|
108
|
+
onMouseMove={handleMouseMove}
|
|
113
109
|
onMove={handleMove}
|
|
114
110
|
onLoad={handleLoad}
|
|
115
111
|
>
|
|
116
|
-
|
|
112
|
+
{@render children?.()}
|
|
117
113
|
</Map>
|
|
118
114
|
```
|
|
119
115
|
|
|
@@ -236,7 +232,7 @@ MapLibre 5 bundles its worker and needs none of this.
|
|
|
236
232
|
|
|
237
233
|
<!-- Custom marker with popup -->
|
|
238
234
|
<Marker
|
|
239
|
-
|
|
235
|
+
coordinates={[-122.4, 37.8]}
|
|
240
236
|
anchor="bottom"
|
|
241
237
|
draggable={true}
|
|
242
238
|
onClick={handleClick}
|
|
@@ -248,11 +244,9 @@ MapLibre 5 bundles its worker and needs none of this.
|
|
|
248
244
|
</Marker>
|
|
249
245
|
|
|
250
246
|
<!-- Popup with card styling -->
|
|
251
|
-
<Popup
|
|
247
|
+
<Popup coordinates={[-122.4, 37.8]} anchor="bottom" closeOnClick={false}>
|
|
252
248
|
<PopupCard>
|
|
253
|
-
<PopupHeader
|
|
254
|
-
<h3>Location Name</h3>
|
|
255
|
-
</PopupHeader>
|
|
249
|
+
<PopupHeader title="Location Name" badge="New" />
|
|
256
250
|
<PopupContent>
|
|
257
251
|
<p>Description goes here</p>
|
|
258
252
|
</PopupContent>
|
|
@@ -263,6 +257,29 @@ MapLibre 5 bundles its worker and needs none of this.
|
|
|
263
257
|
</Popup>
|
|
264
258
|
```
|
|
265
259
|
|
|
260
|
+
### Framing data that changes
|
|
261
|
+
|
|
262
|
+
`bounds` frames the map when it is created. To re-frame later, give `boundsKey`:
|
|
263
|
+
the map fits `bounds` again whenever the key changes (objects and arrays compare
|
|
264
|
+
by value). Pass the bounds themselves to follow every change, or a narrower key
|
|
265
|
+
so that only some changes move the camera.
|
|
266
|
+
|
|
267
|
+
```svelte
|
|
268
|
+
<script lang="ts">
|
|
269
|
+
import { Map, FitBoundsControl } from '@classic-homes/maps-svelte';
|
|
270
|
+
import { boundsOfPositions, padBounds } from '@classic-homes/maps-core';
|
|
271
|
+
|
|
272
|
+
let { stops } = $props();
|
|
273
|
+
const raw = $derived(boundsOfPositions(stops.map((s) => [s.lng, s.lat])));
|
|
274
|
+
const bounds = $derived(raw ? padBounds(raw, { ratio: 0.1 }) : undefined);
|
|
275
|
+
</script>
|
|
276
|
+
|
|
277
|
+
<Map title="Route" {bounds} boundsKey={bounds} boundsPadding={48} boundsMaxZoom={16}>
|
|
278
|
+
<!-- "Show all" button: frames the bounds, north-up, honouring reduced motion -->
|
|
279
|
+
<FitBoundsControl {bounds} position="top-left" />
|
|
280
|
+
</Map>
|
|
281
|
+
```
|
|
282
|
+
|
|
266
283
|
### Controls
|
|
267
284
|
|
|
268
285
|
```svelte
|
|
@@ -336,14 +353,15 @@ MapLibre 5 bundles its worker and needs none of this.
|
|
|
336
353
|
<script lang="ts">
|
|
337
354
|
import { useMapTheme } from '@classic-homes/maps-svelte';
|
|
338
355
|
|
|
339
|
-
|
|
356
|
+
let preference = $state<'light' | 'dark' | 'auto'>('auto');
|
|
357
|
+
const mapTheme = useMapTheme(() => preference);
|
|
340
358
|
</script>
|
|
341
359
|
|
|
342
|
-
<Map
|
|
343
|
-
|
|
360
|
+
<Map title="Themed map" style={mapTheme.style}>
|
|
361
|
+
{@render children?.()}
|
|
344
362
|
</Map>
|
|
345
|
-
<button onclick={
|
|
346
|
-
{isDark
|
|
363
|
+
<button onclick={() => (preference = mapTheme.isDark ? 'light' : 'dark')}>
|
|
364
|
+
{mapTheme.isDark ? 'Light Mode' : 'Dark Mode'}
|
|
347
365
|
</button>
|
|
348
366
|
```
|
|
349
367
|
|
|
@@ -1,28 +1,61 @@
|
|
|
1
|
+
<script lang="ts" module>
|
|
2
|
+
const WEBGL_FAILURE = /webgl|graphics context/i;
|
|
3
|
+
|
|
4
|
+
/** The line under the message: what a visitor can do about the failure */
|
|
5
|
+
export function mapErrorHint(message: string, detail?: string | null): string {
|
|
6
|
+
return WEBGL_FAILURE.test(`${message} ${detail ?? ''}`)
|
|
7
|
+
? "This browser could not start the map's graphics. Try another browser."
|
|
8
|
+
: 'Check your connection and try again';
|
|
9
|
+
}
|
|
10
|
+
</script>
|
|
11
|
+
|
|
1
12
|
<script lang="ts">
|
|
2
13
|
import { cn } from '../../utils.js';
|
|
3
14
|
|
|
4
15
|
interface Props {
|
|
5
16
|
message?: string;
|
|
17
|
+
/** Line under the message; by default it tells a WebGL failure from a network one */
|
|
18
|
+
hint?: string;
|
|
19
|
+
/**
|
|
20
|
+
* The raw failure (MapLibre's own text is often a wall of JSON), shown only
|
|
21
|
+
* behind a "Technical details" disclosure
|
|
22
|
+
*/
|
|
23
|
+
detail?: string | null;
|
|
6
24
|
height?: number | string;
|
|
7
25
|
onRetry?: () => void;
|
|
26
|
+
retryLabel?: string;
|
|
27
|
+
/** A way forward that does not need the map, e.g. "Switch to list view" */
|
|
28
|
+
actionLabel?: string;
|
|
29
|
+
onAction?: () => void;
|
|
8
30
|
class?: string;
|
|
9
31
|
}
|
|
10
32
|
|
|
11
|
-
let {
|
|
33
|
+
let {
|
|
34
|
+
message = 'Failed to load map',
|
|
35
|
+
hint,
|
|
36
|
+
detail = null,
|
|
37
|
+
height = 400,
|
|
38
|
+
onRetry,
|
|
39
|
+
retryLabel = 'Retry',
|
|
40
|
+
actionLabel,
|
|
41
|
+
onAction,
|
|
42
|
+
class: className,
|
|
43
|
+
}: Props = $props();
|
|
12
44
|
|
|
13
45
|
const heightStyle = $derived(typeof height === 'number' ? `${height}px` : height);
|
|
46
|
+
const hintText = $derived(hint ?? mapErrorHint(message, detail));
|
|
47
|
+
const buttonClass =
|
|
48
|
+
'min-h-[44px] rounded-md px-4 py-2 text-sm font-medium shadow-sm focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2';
|
|
14
49
|
</script>
|
|
15
50
|
|
|
16
51
|
<div
|
|
17
52
|
class={cn(
|
|
18
|
-
'flex flex-col items-center justify-center rounded-lg border border-destructive bg-background',
|
|
53
|
+
'flex flex-col items-center justify-center overflow-y-auto rounded-lg border border-destructive bg-background p-4',
|
|
19
54
|
className
|
|
20
55
|
)}
|
|
21
56
|
style:height={heightStyle}
|
|
22
|
-
role="alert"
|
|
23
|
-
aria-live="polite"
|
|
24
57
|
>
|
|
25
|
-
<div class="flex flex-col items-center gap-3 text-center">
|
|
58
|
+
<div class="flex max-w-md flex-col items-center gap-3 text-center">
|
|
26
59
|
<svg
|
|
27
60
|
class="h-10 w-10 text-destructive"
|
|
28
61
|
xmlns="http://www.w3.org/2000/svg"
|
|
@@ -40,17 +73,39 @@
|
|
|
40
73
|
d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"
|
|
41
74
|
/>
|
|
42
75
|
</svg>
|
|
43
|
-
|
|
76
|
+
<!-- The live region holds the message only: wrapping the buttons and the
|
|
77
|
+
disclosure would re-announce them on any change inside -->
|
|
78
|
+
<div class="space-y-1" role="alert" aria-live="polite">
|
|
44
79
|
<p class="text-sm font-medium text-destructive">{message}</p>
|
|
45
|
-
<p class="text-xs text-muted-foreground">
|
|
80
|
+
<p class="text-xs text-muted-foreground">{hintText}</p>
|
|
46
81
|
</div>
|
|
47
|
-
{#if onRetry}
|
|
48
|
-
<
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
82
|
+
{#if (onAction && actionLabel) || onRetry}
|
|
83
|
+
<div class="mt-2 flex flex-wrap items-center justify-center gap-2">
|
|
84
|
+
{#if onAction && actionLabel}
|
|
85
|
+
<button
|
|
86
|
+
type="button"
|
|
87
|
+
onclick={onAction}
|
|
88
|
+
class={cn(buttonClass, 'bg-primary text-primary-foreground hover:bg-primary/90')}
|
|
89
|
+
>
|
|
90
|
+
{actionLabel}
|
|
91
|
+
</button>
|
|
92
|
+
{/if}
|
|
93
|
+
{#if onRetry}
|
|
94
|
+
<button
|
|
95
|
+
type="button"
|
|
96
|
+
onclick={onRetry}
|
|
97
|
+
class={cn(buttonClass, 'border border-input bg-background hover:bg-muted')}
|
|
98
|
+
>
|
|
99
|
+
{retryLabel}
|
|
100
|
+
</button>
|
|
101
|
+
{/if}
|
|
102
|
+
</div>
|
|
103
|
+
{/if}
|
|
104
|
+
{#if detail}
|
|
105
|
+
<details class="w-full text-left">
|
|
106
|
+
<summary class="cursor-pointer text-xs text-muted-foreground">Technical details</summary>
|
|
107
|
+
<p class="mt-1 max-h-24 overflow-auto break-all text-xs text-muted-foreground">{detail}</p>
|
|
108
|
+
</details>
|
|
54
109
|
{/if}
|
|
55
110
|
</div>
|
|
56
111
|
</div>
|
|
@@ -1,7 +1,20 @@
|
|
|
1
|
+
/** The line under the message: what a visitor can do about the failure */
|
|
2
|
+
export declare function mapErrorHint(message: string, detail?: string | null): string;
|
|
1
3
|
interface Props {
|
|
2
4
|
message?: string;
|
|
5
|
+
/** Line under the message; by default it tells a WebGL failure from a network one */
|
|
6
|
+
hint?: string;
|
|
7
|
+
/**
|
|
8
|
+
* The raw failure (MapLibre's own text is often a wall of JSON), shown only
|
|
9
|
+
* behind a "Technical details" disclosure
|
|
10
|
+
*/
|
|
11
|
+
detail?: string | null;
|
|
3
12
|
height?: number | string;
|
|
4
13
|
onRetry?: () => void;
|
|
14
|
+
retryLabel?: string;
|
|
15
|
+
/** A way forward that does not need the map, e.g. "Switch to list view" */
|
|
16
|
+
actionLabel?: string;
|
|
17
|
+
onAction?: () => void;
|
|
5
18
|
class?: string;
|
|
6
19
|
}
|
|
7
20
|
declare const MapError: import("svelte").Component<Props, {}, "">;
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
<script lang="ts" module>
|
|
2
|
+
import type { BoundsArray, ExtendedControlPosition } from '@classic-homes/maps-core';
|
|
3
|
+
|
|
4
|
+
export interface FitBoundsControlProps {
|
|
5
|
+
/** What to frame; the button is disabled while this is undefined */
|
|
6
|
+
bounds?: BoundsArray | null;
|
|
7
|
+
/**
|
|
8
|
+
* Padding in pixels. Default: a fifth of the map's height, held between
|
|
9
|
+
* 12 and 60, so a short phone map is not framed into a sliver.
|
|
10
|
+
*/
|
|
11
|
+
padding?: number | { top: number; right: number; bottom: number; left: number };
|
|
12
|
+
/** Highest zoom the fit may reach (default 17) */
|
|
13
|
+
maxZoom?: number;
|
|
14
|
+
/** Also turn the map back to north-up (default true) */
|
|
15
|
+
resetBearing?: boolean;
|
|
16
|
+
/** Control position (default top-right) */
|
|
17
|
+
position?: ExtendedControlPosition;
|
|
18
|
+
/** Accessible name and tooltip (default "Show all results") */
|
|
19
|
+
label?: string;
|
|
20
|
+
/** Called before the map moves, e.g. to clear a selection */
|
|
21
|
+
onFit?: () => void;
|
|
22
|
+
class?: string;
|
|
23
|
+
}
|
|
24
|
+
</script>
|
|
25
|
+
|
|
26
|
+
<script lang="ts">
|
|
27
|
+
/**
|
|
28
|
+
* A map button that frames given bounds: "zoom back out to everything".
|
|
29
|
+
* Matches the other on-map buttons (44px, card surface) and honours reduced
|
|
30
|
+
* motion.
|
|
31
|
+
*/
|
|
32
|
+
import type * as maplibregl from 'maplibre-gl';
|
|
33
|
+
import CustomControl from './CustomControl.svelte';
|
|
34
|
+
import { useMapContext } from '../../composables/useMapContext.svelte.js';
|
|
35
|
+
import { useReducedMotion } from '../../composables/useReducedMotion.svelte.js';
|
|
36
|
+
import { cn } from '../../utils.js';
|
|
37
|
+
|
|
38
|
+
let {
|
|
39
|
+
bounds,
|
|
40
|
+
padding,
|
|
41
|
+
maxZoom = 17,
|
|
42
|
+
resetBearing = true,
|
|
43
|
+
position = 'top-right',
|
|
44
|
+
label = 'Show all results',
|
|
45
|
+
onFit,
|
|
46
|
+
class: className,
|
|
47
|
+
}: FitBoundsControlProps = $props();
|
|
48
|
+
|
|
49
|
+
const ctx = useMapContext();
|
|
50
|
+
const reducedMotion = useReducedMotion();
|
|
51
|
+
|
|
52
|
+
function fit() {
|
|
53
|
+
const map = ctx.map;
|
|
54
|
+
if (!map || !bounds) return;
|
|
55
|
+
onFit?.();
|
|
56
|
+
const auto = Math.min(60, Math.max(12, map.getContainer().clientHeight / 5));
|
|
57
|
+
map.fitBounds(bounds as [[number, number], [number, number]], {
|
|
58
|
+
padding: (padding ?? auto) as number | maplibregl.PaddingOptions,
|
|
59
|
+
maxZoom,
|
|
60
|
+
...(resetBearing ? { bearing: 0 } : {}),
|
|
61
|
+
animate: !reducedMotion.value,
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
</script>
|
|
65
|
+
|
|
66
|
+
<CustomControl {position} priority="normal">
|
|
67
|
+
<button
|
|
68
|
+
type="button"
|
|
69
|
+
class={cn(
|
|
70
|
+
'w-[44px] h-[44px] flex items-center justify-center',
|
|
71
|
+
'bg-card rounded shadow-lg border border-border',
|
|
72
|
+
'hover:bg-muted cursor-pointer text-foreground',
|
|
73
|
+
'disabled:cursor-not-allowed disabled:opacity-50',
|
|
74
|
+
className
|
|
75
|
+
)}
|
|
76
|
+
aria-label={label}
|
|
77
|
+
title={label}
|
|
78
|
+
disabled={!bounds}
|
|
79
|
+
onclick={fit}
|
|
80
|
+
>
|
|
81
|
+
<svg
|
|
82
|
+
width="20"
|
|
83
|
+
height="20"
|
|
84
|
+
viewBox="0 0 24 24"
|
|
85
|
+
fill="none"
|
|
86
|
+
stroke="currentColor"
|
|
87
|
+
stroke-width="2"
|
|
88
|
+
stroke-linecap="round"
|
|
89
|
+
stroke-linejoin="round"
|
|
90
|
+
aria-hidden="true"
|
|
91
|
+
>
|
|
92
|
+
<path d="M8 3H5a2 2 0 0 0-2 2v3" />
|
|
93
|
+
<path d="M21 8V5a2 2 0 0 0-2-2h-3" />
|
|
94
|
+
<path d="M3 16v3a2 2 0 0 0 2 2h3" />
|
|
95
|
+
<path d="M16 21h3a2 2 0 0 0 2-2v-3" />
|
|
96
|
+
</svg>
|
|
97
|
+
</button>
|
|
98
|
+
</CustomControl>
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { BoundsArray, ExtendedControlPosition } from '@classic-homes/maps-core';
|
|
2
|
+
export interface FitBoundsControlProps {
|
|
3
|
+
/** What to frame; the button is disabled while this is undefined */
|
|
4
|
+
bounds?: BoundsArray | null;
|
|
5
|
+
/**
|
|
6
|
+
* Padding in pixels. Default: a fifth of the map's height, held between
|
|
7
|
+
* 12 and 60, so a short phone map is not framed into a sliver.
|
|
8
|
+
*/
|
|
9
|
+
padding?: number | {
|
|
10
|
+
top: number;
|
|
11
|
+
right: number;
|
|
12
|
+
bottom: number;
|
|
13
|
+
left: number;
|
|
14
|
+
};
|
|
15
|
+
/** Highest zoom the fit may reach (default 17) */
|
|
16
|
+
maxZoom?: number;
|
|
17
|
+
/** Also turn the map back to north-up (default true) */
|
|
18
|
+
resetBearing?: boolean;
|
|
19
|
+
/** Control position (default top-right) */
|
|
20
|
+
position?: ExtendedControlPosition;
|
|
21
|
+
/** Accessible name and tooltip (default "Show all results") */
|
|
22
|
+
label?: string;
|
|
23
|
+
/** Called before the map moves, e.g. to clear a selection */
|
|
24
|
+
onFit?: () => void;
|
|
25
|
+
class?: string;
|
|
26
|
+
}
|
|
27
|
+
declare const FitBoundsControl: import("svelte").Component<FitBoundsControlProps, {}, "">;
|
|
28
|
+
type FitBoundsControl = ReturnType<typeof FitBoundsControl>;
|
|
29
|
+
export default FitBoundsControl;
|
|
@@ -4,3 +4,4 @@ export { default as CoordinateDisplay } from './CoordinateDisplay.svelte';
|
|
|
4
4
|
export { default as BasemapSwitcher } from './BasemapSwitcher.svelte';
|
|
5
5
|
export { default as LayerManager } from './LayerManager.svelte';
|
|
6
6
|
export { default as CustomControl, type CustomControlProps } from './CustomControl.svelte';
|
|
7
|
+
export { default as FitBoundsControl, type FitBoundsControlProps } from './FitBoundsControl.svelte';
|
|
@@ -4,3 +4,4 @@ export { default as CoordinateDisplay } from './CoordinateDisplay.svelte';
|
|
|
4
4
|
export { default as BasemapSwitcher } from './BasemapSwitcher.svelte';
|
|
5
5
|
export { default as LayerManager } from './LayerManager.svelte';
|
|
6
6
|
export { default as CustomControl } from './CustomControl.svelte';
|
|
7
|
+
export { default as FitBoundsControl } from './FitBoundsControl.svelte';
|
|
@@ -53,6 +53,8 @@
|
|
|
53
53
|
pitch = 0,
|
|
54
54
|
bounds,
|
|
55
55
|
boundsPadding,
|
|
56
|
+
boundsMaxZoom,
|
|
57
|
+
boundsKey,
|
|
56
58
|
minZoom,
|
|
57
59
|
maxZoom,
|
|
58
60
|
maxBounds,
|
|
@@ -349,8 +351,13 @@
|
|
|
349
351
|
mapLoaded = true;
|
|
350
352
|
|
|
351
353
|
if (bounds) {
|
|
354
|
+
// The container may have been sized after the map was created (a
|
|
355
|
+
// layout that measures itself on mount), so fit at its real size
|
|
356
|
+
newMap.resize();
|
|
357
|
+
framedKey = { key: keyOf(untrack(() => boundsKey)) };
|
|
352
358
|
newMap.fitBounds(bounds as [[number, number], [number, number]], {
|
|
353
359
|
padding: boundsPadding as number | maplibregl.PaddingOptions | undefined,
|
|
360
|
+
maxZoom: boundsMaxZoom,
|
|
354
361
|
animate: animation && !reducedMotion.value,
|
|
355
362
|
});
|
|
356
363
|
}
|
|
@@ -546,6 +553,28 @@
|
|
|
546
553
|
});
|
|
547
554
|
});
|
|
548
555
|
|
|
556
|
+
// `boundsKey`: a change after load re-frames the map to `bounds`. The load
|
|
557
|
+
// handler's own fit counts as applying the key in force at that moment.
|
|
558
|
+
const keyOf = (value: unknown) =>
|
|
559
|
+
value !== null && typeof value === 'object' ? JSON.stringify(value) : value;
|
|
560
|
+
let framedKey: { key: unknown } | null = null;
|
|
561
|
+
$effect(() => {
|
|
562
|
+
const key = keyOf(boundsKey);
|
|
563
|
+
const target = bounds;
|
|
564
|
+
if (!map || !mapLoaded || boundsKey === undefined || !target) return;
|
|
565
|
+
const live = map;
|
|
566
|
+
untrack(() => {
|
|
567
|
+
if (framedKey && framedKey.key === key) return;
|
|
568
|
+
framedKey = { key };
|
|
569
|
+
live.resize();
|
|
570
|
+
live.fitBounds(target as [[number, number], [number, number]], {
|
|
571
|
+
padding: boundsPadding as number | maplibregl.PaddingOptions | undefined,
|
|
572
|
+
maxZoom: boundsMaxZoom,
|
|
573
|
+
animate: animation && !reducedMotion.value,
|
|
574
|
+
});
|
|
575
|
+
});
|
|
576
|
+
});
|
|
577
|
+
|
|
549
578
|
// Clear programmatic override when customStyle prop changes
|
|
550
579
|
$effect(() => {
|
|
551
580
|
if (customStyle) {
|
|
@@ -2,4 +2,4 @@ export { MapContainer, MapSkeleton, MapError, MapEmpty } from './base/index.js';
|
|
|
2
2
|
export { Map, Source, Marker, Popup, PopupCard, PopupHeader, PopupContent, PopupFooter, } from './core/index.js';
|
|
3
3
|
export { FillLayer, LineLayer, CircleLayer, SymbolLayer, FillExtrusionLayer, HeatmapLayer, useLayer, type UseLayerOptions, type SvelteFeatureClickEventParams, type SvelteFeatureHoverEventParams, } from './layers/index.js';
|
|
4
4
|
export { DeckOverlay } from './deck/index.js';
|
|
5
|
-
export { Legend, LegendGroup, CoordinateDisplay, BasemapSwitcher, LayerManager, CustomControl, type CustomControlProps, } from './controls/index.js';
|
|
5
|
+
export { Legend, LegendGroup, CoordinateDisplay, BasemapSwitcher, LayerManager, CustomControl, type CustomControlProps, FitBoundsControl, type FitBoundsControlProps, } from './controls/index.js';
|
|
@@ -7,4 +7,4 @@ export { FillLayer, LineLayer, CircleLayer, SymbolLayer, FillExtrusionLayer, Hea
|
|
|
7
7
|
// Deck.gl components
|
|
8
8
|
export { DeckOverlay } from './deck/index.js';
|
|
9
9
|
// Control components
|
|
10
|
-
export { Legend, LegendGroup, CoordinateDisplay, BasemapSwitcher, LayerManager, CustomControl, } from './controls/index.js';
|
|
10
|
+
export { Legend, LegendGroup, CoordinateDisplay, BasemapSwitcher, LayerManager, CustomControl, FitBoundsControl, } from './controls/index.js';
|
package/dist/lib/index.d.ts
CHANGED
|
@@ -3,12 +3,12 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Svelte MapLibre components for the Classic Theme design system
|
|
5
5
|
*/
|
|
6
|
-
export { MapContainer, MapSkeleton, MapError, MapEmpty, Map, Source, Marker, Popup, PopupCard, PopupHeader, PopupContent, PopupFooter, useLayer, type UseLayerOptions, FillLayer, LineLayer, CircleLayer, SymbolLayer, FillExtrusionLayer, HeatmapLayer, Legend, LegendGroup, CoordinateDisplay, BasemapSwitcher, LayerManager, CustomControl, type CustomControlProps, DeckOverlay, type SvelteFeatureClickEventParams, type SvelteFeatureHoverEventParams, } from './components/index.js';
|
|
6
|
+
export { MapContainer, MapSkeleton, MapError, MapEmpty, Map, Source, Marker, Popup, PopupCard, PopupHeader, PopupContent, PopupFooter, useLayer, type UseLayerOptions, FillLayer, LineLayer, CircleLayer, SymbolLayer, FillExtrusionLayer, HeatmapLayer, Legend, LegendGroup, CoordinateDisplay, BasemapSwitcher, LayerManager, CustomControl, type CustomControlProps, FitBoundsControl, type FitBoundsControlProps, DeckOverlay, type SvelteFeatureClickEventParams, type SvelteFeatureHoverEventParams, } from './components/index.js';
|
|
7
7
|
export { useMapTheme, useReducedMotion, useMapContext, tryUseMapContext, useMapInstance, useControlPosition, type MapContextValue, type UseControlPositionOptions, type UseControlPositionResult, } from './composables/index.js';
|
|
8
8
|
export { cn } from './utils.js';
|
|
9
9
|
export type { LngLat, MapBounds, BoundsArray, MapViewport, GeoJSONFeature, GeoJSONFeatureCollection, MarkerData, MapClickEventParams, MapHoverEventParams, FeatureClickEventParams, FeatureHoverEventParams, MarkerClickEventParams, MarkerDragEventParams, MapMoveEventParams, BaseMapProps, MapProps, SourceProps, FillLayerProps, LineLayerProps, CircleLayerProps, SymbolLayerProps, FillExtrusionLayerProps, HeatmapLayerProps, MarkerProps, PopupProps, LegendItem, GradientStop, LegendProps, CoordinateDisplayProps, LegendConfig, LegendGroupProps, BasemapProvider, BasemapCategory, BasemapDefinition, BasemapApiKeys, BasemapSwitcherProps, OverlayLayerCategory, OverlayLayerDefinition, OverlayLayerState, OverlayApiKeys, LayerManagerProps, ExtendedControlPosition, ControlPriority, ZIndexLayer, ControlType, ControlOffset, } from '@classic-homes/maps-core';
|
|
10
10
|
export { CATEGORY_META, SCHOOL_DISTRICTS, CITY_LIMITS, ZONING_DISTRICTS, PARKS, TRAILS, SPORTS_FACILITIES, TRANSIT_ROUTES, BIKE_LANES, FLOOD_ZONES, WATERSHEDS, BUILTIN_OVERLAY_LAYERS, resolveLayerSourceUrl, getLayerStyleForTheme, searchLayers, getLayersByCategory, groupLayersByCategory, getLayerCategories, createInitialLayerStates, toggleLayerVisibility, setLayerOpacity, } from '@classic-homes/maps-core';
|
|
11
|
-
export { THEME_LIGHT, THEME_DARK, lightTheme, darkTheme, lightBasicStyle, darkBasicStyle, generateMapDescription, formatCoordinates, formatDistance, formatArea, createHoverExpression, createSelectionExpression, getHighlightStyle, getSelectionStyle, calculateBounds, extendBounds, combineBounds, isValidBounds, loadGeoJSON, validateGeoJSON, calculateCentroid, countFeaturesByType, filterByGeometryType, DEFAULT_BASEMAP, SATELLITE_BASEMAP, TOPO_BASEMAP, PRIMARY_BASEMAPS, BUILTIN_BASEMAPS, FREE_BASEMAPS, OSM_STANDARD, resolveBasemapStyle, getAvailableBasemaps, } from '@classic-homes/maps-core';
|
|
11
|
+
export { THEME_LIGHT, THEME_DARK, lightTheme, darkTheme, lightBasicStyle, darkBasicStyle, generateMapDescription, formatCoordinates, formatDistance, formatArea, createHoverExpression, createSelectionExpression, getHighlightStyle, getSelectionStyle, calculateBounds, extendBounds, combineBounds, isValidBounds, boundsOfPositions, padBounds, loadGeoJSON, validateGeoJSON, calculateCentroid, countFeaturesByType, filterByGeometryType, DEFAULT_BASEMAP, SATELLITE_BASEMAP, TOPO_BASEMAP, PRIMARY_BASEMAPS, BUILTIN_BASEMAPS, FREE_BASEMAPS, OSM_STANDARD, resolveBasemapStyle, getAvailableBasemaps, } from '@classic-homes/maps-core';
|
|
12
12
|
export type { LoadGeoJSONOptions, LoadGeoJSONResult, ValidationResult, ClusterFeatureProperties, ClusterExpandOptions, } from '@classic-homes/maps-core';
|
|
13
13
|
export { isClusterFeature, getClusterExpansionZoom, getClusterChildren, getClusterLeaves, expandCluster, getClusterBounds, expandClusterToBounds, createClusterStyles, createClusterCirclePaint, createClusterTextLayout, } from '@classic-homes/maps-core';
|
|
14
14
|
export type { ClusterCircleStyleOptions, ClusterTextStyleOptions, UnclusteredPointStyleOptions, ClusterLayerStyles, } from '@classic-homes/maps-core';
|
package/dist/lib/index.js
CHANGED
|
@@ -12,7 +12,7 @@ Map, Source, Marker, Popup, PopupCard, PopupHeader, PopupContent, PopupFooter,
|
|
|
12
12
|
// Layers
|
|
13
13
|
useLayer, FillLayer, LineLayer, CircleLayer, SymbolLayer, FillExtrusionLayer, HeatmapLayer,
|
|
14
14
|
// Controls
|
|
15
|
-
Legend, LegendGroup, CoordinateDisplay, BasemapSwitcher, LayerManager, CustomControl,
|
|
15
|
+
Legend, LegendGroup, CoordinateDisplay, BasemapSwitcher, LayerManager, CustomControl, FitBoundsControl,
|
|
16
16
|
// Deck.gl
|
|
17
17
|
DeckOverlay, } from './components/index.js';
|
|
18
18
|
// Composables
|
|
@@ -24,7 +24,7 @@ export { CATEGORY_META, SCHOOL_DISTRICTS, CITY_LIMITS, ZONING_DISTRICTS, PARKS,
|
|
|
24
24
|
// Re-export theme and utilities from maps-core
|
|
25
25
|
export { THEME_LIGHT, THEME_DARK, lightTheme, darkTheme, lightBasicStyle, darkBasicStyle, generateMapDescription, formatCoordinates, formatDistance, formatArea, createHoverExpression, createSelectionExpression, getHighlightStyle, getSelectionStyle,
|
|
26
26
|
// Bounds utilities
|
|
27
|
-
calculateBounds, extendBounds, combineBounds, isValidBounds,
|
|
27
|
+
calculateBounds, extendBounds, combineBounds, isValidBounds, boundsOfPositions, padBounds,
|
|
28
28
|
// Data utilities
|
|
29
29
|
loadGeoJSON, validateGeoJSON, calculateCentroid, countFeaturesByType, filterByGeometryType,
|
|
30
30
|
// Basemap utilities
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@classic-homes/maps-svelte",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.0",
|
|
4
4
|
"description": "Svelte MapLibre components for Classic Theme",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"maps",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"test": "vitest run"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@classic-homes/maps-core": "^0.
|
|
40
|
+
"@classic-homes/maps-core": "^0.10.0",
|
|
41
41
|
"@classic-homes/theme-svelte": "*",
|
|
42
42
|
"@classic-homes/theme-tokens": "*",
|
|
43
43
|
"clsx": "^2.1.0",
|