maplibrex-svelte 0.1.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/LICENSE +21 -0
- package/README.md +300 -0
- package/dist/components/MapLibre.svelte +258 -0
- package/dist/components/MapLibre.svelte.d.ts +42 -0
- package/dist/components/controls/AttributionControl.svelte +21 -0
- package/dist/components/controls/AttributionControl.svelte.d.ts +11 -0
- package/dist/components/controls/Control.svelte +58 -0
- package/dist/components/controls/Control.svelte.d.ts +33 -0
- package/dist/components/controls/CustomControl.svelte +46 -0
- package/dist/components/controls/CustomControl.svelte.d.ts +13 -0
- package/dist/components/controls/FullscreenControl.svelte +32 -0
- package/dist/components/controls/FullscreenControl.svelte.d.ts +12 -0
- package/dist/components/controls/GeolocateControl.svelte +32 -0
- package/dist/components/controls/GeolocateControl.svelte.d.ts +12 -0
- package/dist/components/controls/GlobeControl.svelte +16 -0
- package/dist/components/controls/GlobeControl.svelte.d.ts +11 -0
- package/dist/components/controls/LogoControl.svelte +21 -0
- package/dist/components/controls/LogoControl.svelte.d.ts +11 -0
- package/dist/components/controls/NavigationControl.svelte +21 -0
- package/dist/components/controls/NavigationControl.svelte.d.ts +11 -0
- package/dist/components/controls/ScaleControl.svelte +21 -0
- package/dist/components/controls/ScaleControl.svelte.d.ts +11 -0
- package/dist/components/controls/TerrainControl.svelte +21 -0
- package/dist/components/controls/TerrainControl.svelte.d.ts +11 -0
- package/dist/components/data/FeatureState.svelte +56 -0
- package/dist/components/data/FeatureState.svelte.d.ts +13 -0
- package/dist/components/data/Protocol.svelte +24 -0
- package/dist/components/data/Protocol.svelte.d.ts +9 -0
- package/dist/components/layers/BackgroundLayer.svelte +21 -0
- package/dist/components/layers/BackgroundLayer.svelte.d.ts +17 -0
- package/dist/components/layers/CircleLayer.svelte +25 -0
- package/dist/components/layers/CircleLayer.svelte.d.ts +21 -0
- package/dist/components/layers/ColorReliefLayer.svelte +25 -0
- package/dist/components/layers/ColorReliefLayer.svelte.d.ts +21 -0
- package/dist/components/layers/CustomLayer.svelte +35 -0
- package/dist/components/layers/CustomLayer.svelte.d.ts +13 -0
- package/dist/components/layers/FillExtrusionLayer.svelte +25 -0
- package/dist/components/layers/FillExtrusionLayer.svelte.d.ts +21 -0
- package/dist/components/layers/FillLayer.svelte +25 -0
- package/dist/components/layers/FillLayer.svelte.d.ts +21 -0
- package/dist/components/layers/HeatmapLayer.svelte +25 -0
- package/dist/components/layers/HeatmapLayer.svelte.d.ts +21 -0
- package/dist/components/layers/HillshadeLayer.svelte +25 -0
- package/dist/components/layers/HillshadeLayer.svelte.d.ts +21 -0
- package/dist/components/layers/Layer.svelte +204 -0
- package/dist/components/layers/Layer.svelte.d.ts +29 -0
- package/dist/components/layers/LineLayer.svelte +25 -0
- package/dist/components/layers/LineLayer.svelte.d.ts +21 -0
- package/dist/components/layers/RasterLayer.svelte +25 -0
- package/dist/components/layers/RasterLayer.svelte.d.ts +21 -0
- package/dist/components/layers/SymbolLayer.svelte +25 -0
- package/dist/components/layers/SymbolLayer.svelte.d.ts +21 -0
- package/dist/components/overlays/Marker.svelte +204 -0
- package/dist/components/overlays/Marker.svelte.d.ts +27 -0
- package/dist/components/overlays/Popup.svelte +184 -0
- package/dist/components/overlays/Popup.svelte.d.ts +24 -0
- package/dist/components/sources/CanvasSource.svelte +16 -0
- package/dist/components/sources/CanvasSource.svelte.d.ts +13 -0
- package/dist/components/sources/GeoJSONSource.svelte +16 -0
- package/dist/components/sources/GeoJSONSource.svelte.d.ts +13 -0
- package/dist/components/sources/ImageSource.svelte +16 -0
- package/dist/components/sources/ImageSource.svelte.d.ts +13 -0
- package/dist/components/sources/RasterDEMSource.svelte +16 -0
- package/dist/components/sources/RasterDEMSource.svelte.d.ts +13 -0
- package/dist/components/sources/RasterSource.svelte +16 -0
- package/dist/components/sources/RasterSource.svelte.d.ts +13 -0
- package/dist/components/sources/Source.svelte +88 -0
- package/dist/components/sources/Source.svelte.d.ts +14 -0
- package/dist/components/sources/VectorSource.svelte +16 -0
- package/dist/components/sources/VectorSource.svelte.d.ts +13 -0
- package/dist/components/sources/VideoSource.svelte +16 -0
- package/dist/components/sources/VideoSource.svelte.d.ts +13 -0
- package/dist/components/style/GlobalState.svelte +67 -0
- package/dist/components/style/GlobalState.svelte.d.ts +8 -0
- package/dist/components/style/Image.svelte +92 -0
- package/dist/components/style/Image.svelte.d.ts +14 -0
- package/dist/components/style/Light.svelte +31 -0
- package/dist/components/style/Light.svelte.d.ts +4 -0
- package/dist/components/style/Projection.svelte +31 -0
- package/dist/components/style/Projection.svelte.d.ts +4 -0
- package/dist/components/style/Sky.svelte +31 -0
- package/dist/components/style/Sky.svelte.d.ts +4 -0
- package/dist/components/style/Terrain.svelte +50 -0
- package/dist/components/style/Terrain.svelte.d.ts +9 -0
- package/dist/context.d.ts +41 -0
- package/dist/context.js +31 -0
- package/dist/index.d.ts +57 -0
- package/dist/index.js +48 -0
- package/dist/internal/bind-events.svelte.d.ts +26 -0
- package/dist/internal/bind-events.svelte.js +49 -0
- package/dist/internal/camera.d.ts +15 -0
- package/dist/internal/camera.js +33 -0
- package/dist/internal/deep-equal.d.ts +6 -0
- package/dist/internal/deep-equal.js +25 -0
- package/dist/internal/diff.d.ts +15 -0
- package/dist/internal/diff.js +29 -0
- package/dist/internal/events.d.ts +22 -0
- package/dist/internal/events.js +40 -0
- package/dist/internal/interactions.d.ts +22 -0
- package/dist/internal/interactions.js +36 -0
- package/dist/internal/source.d.ts +25 -0
- package/dist/internal/source.js +25 -0
- package/dist/internal/stable-key.d.ts +9 -0
- package/dist/internal/stable-key.js +17 -0
- package/dist/internal/style-ops.d.ts +26 -0
- package/dist/internal/style-ops.js +56 -0
- package/dist/types.d.ts +21 -0
- package/dist/types.js +1 -0
- package/package.json +92 -0
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
<script lang="ts" generics="TControl extends IControl, TOptions">
|
|
2
|
+
import type { ControlPosition, IControl } from 'maplibre-gl';
|
|
3
|
+
import { untrack } from 'svelte';
|
|
4
|
+
import { getMapContext } from '../../context.js';
|
|
5
|
+
import { bindEvents } from '../../internal/bind-events.svelte.js';
|
|
6
|
+
import { stableKey } from '../../internal/stable-key.js';
|
|
7
|
+
|
|
8
|
+
type Props = {
|
|
9
|
+
/** Called once per mount. Kept as a factory so nothing is built on the server. */
|
|
10
|
+
factory: (options: TOptions) => TControl;
|
|
11
|
+
options: TOptions;
|
|
12
|
+
/** @defaultValue 'top-right' */
|
|
13
|
+
position?: ControlPosition;
|
|
14
|
+
/** Read-only binding to the underlying control, for imperative calls. */
|
|
15
|
+
control?: TControl | null;
|
|
16
|
+
} & Record<string, unknown>;
|
|
17
|
+
|
|
18
|
+
let {
|
|
19
|
+
factory,
|
|
20
|
+
options,
|
|
21
|
+
position = 'top-right',
|
|
22
|
+
control = $bindable(null),
|
|
23
|
+
...events
|
|
24
|
+
}: Props = $props();
|
|
25
|
+
|
|
26
|
+
const context = getMapContext();
|
|
27
|
+
const optionsKey = $derived(stableKey(options));
|
|
28
|
+
|
|
29
|
+
// MapLibre controls are configured through their constructor and expose no
|
|
30
|
+
// setters, so an option or position change means recreate, not mutate.
|
|
31
|
+
// Only some MapLibre controls are Evented. Binding blindly would throw on the
|
|
32
|
+
// ones that are not, so the check is what makes this safe for any IControl.
|
|
33
|
+
const eventTarget = $derived(
|
|
34
|
+
control && typeof (control as { on?: unknown }).on === 'function' ? control : null
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
bindEvents(
|
|
38
|
+
() => eventTarget as never,
|
|
39
|
+
() => events
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
$effect(() => {
|
|
43
|
+
const map = context.map;
|
|
44
|
+
const at = position;
|
|
45
|
+
void optionsKey;
|
|
46
|
+
|
|
47
|
+
if (!map) return;
|
|
48
|
+
|
|
49
|
+
const instance = untrack(() => factory(options));
|
|
50
|
+
map.addControl(instance, at);
|
|
51
|
+
control = instance;
|
|
52
|
+
|
|
53
|
+
return () => {
|
|
54
|
+
control = null;
|
|
55
|
+
map.removeControl(instance);
|
|
56
|
+
};
|
|
57
|
+
});
|
|
58
|
+
</script>
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { ControlPosition, IControl } from 'maplibre-gl';
|
|
2
|
+
declare function $$render<TControl extends IControl, TOptions>(): {
|
|
3
|
+
props: {
|
|
4
|
+
/** Called once per mount. Kept as a factory so nothing is built on the server. */
|
|
5
|
+
factory: (options: TOptions) => TControl;
|
|
6
|
+
options: TOptions;
|
|
7
|
+
/** @defaultValue 'top-right' */
|
|
8
|
+
position?: ControlPosition;
|
|
9
|
+
/** Read-only binding to the underlying control, for imperative calls. */
|
|
10
|
+
control?: TControl | null;
|
|
11
|
+
} & Record<string, unknown>;
|
|
12
|
+
exports: {};
|
|
13
|
+
bindings: "control";
|
|
14
|
+
slots: {};
|
|
15
|
+
events: {};
|
|
16
|
+
};
|
|
17
|
+
declare class __sveltets_Render<TControl extends IControl, TOptions> {
|
|
18
|
+
props(): ReturnType<typeof $$render<TControl, TOptions>>['props'];
|
|
19
|
+
events(): ReturnType<typeof $$render<TControl, TOptions>>['events'];
|
|
20
|
+
slots(): ReturnType<typeof $$render<TControl, TOptions>>['slots'];
|
|
21
|
+
bindings(): "control";
|
|
22
|
+
exports(): {};
|
|
23
|
+
}
|
|
24
|
+
interface $$IsomorphicComponent {
|
|
25
|
+
new <TControl extends IControl, TOptions>(options: import('svelte').ComponentConstructorOptions<ReturnType<__sveltets_Render<TControl, TOptions>['props']>>): import('svelte').SvelteComponent<ReturnType<__sveltets_Render<TControl, TOptions>['props']>, ReturnType<__sveltets_Render<TControl, TOptions>['events']>, ReturnType<__sveltets_Render<TControl, TOptions>['slots']>> & {
|
|
26
|
+
$$bindings?: ReturnType<__sveltets_Render<TControl, TOptions>['bindings']>;
|
|
27
|
+
} & ReturnType<__sveltets_Render<TControl, TOptions>['exports']>;
|
|
28
|
+
<TControl extends IControl, TOptions>(internal: unknown, props: ReturnType<__sveltets_Render<TControl, TOptions>['props']> & {}): ReturnType<__sveltets_Render<TControl, TOptions>['exports']>;
|
|
29
|
+
z_$$bindings?: ReturnType<__sveltets_Render<any, any>['bindings']>;
|
|
30
|
+
}
|
|
31
|
+
declare const Control: $$IsomorphicComponent;
|
|
32
|
+
type Control<TControl extends IControl, TOptions> = InstanceType<typeof Control<TControl, TOptions>>;
|
|
33
|
+
export default Control;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { ControlPosition, IControl, Map as MapLibreMap } from 'maplibre-gl';
|
|
3
|
+
import type { Snippet } from 'svelte';
|
|
4
|
+
import { getMapContext } from '../../context.js';
|
|
5
|
+
|
|
6
|
+
type Props = {
|
|
7
|
+
/** @defaultValue 'top-right' */
|
|
8
|
+
position?: ControlPosition;
|
|
9
|
+
class?: string;
|
|
10
|
+
children: Snippet<[{ map: MapLibreMap }]>;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
let { position = 'top-right', class: className, children }: Props = $props();
|
|
14
|
+
|
|
15
|
+
const context = getMapContext();
|
|
16
|
+
|
|
17
|
+
let content = $state<HTMLDivElement | null>(null);
|
|
18
|
+
|
|
19
|
+
// The snippet is rendered into a hidden holder and MapLibre relocates that
|
|
20
|
+
// node into its own control container. Svelte keeps owning the node, so the
|
|
21
|
+
// snippet stays reactive after the move.
|
|
22
|
+
$effect(() => {
|
|
23
|
+
const map = context.map;
|
|
24
|
+
const node = content;
|
|
25
|
+
const at = position;
|
|
26
|
+
|
|
27
|
+
if (!map || !node) return;
|
|
28
|
+
|
|
29
|
+
const control: IControl = {
|
|
30
|
+
onAdd: () => node,
|
|
31
|
+
onRemove: () => node.remove()
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
map.addControl(control, at);
|
|
35
|
+
|
|
36
|
+
return () => map.removeControl(control);
|
|
37
|
+
});
|
|
38
|
+
</script>
|
|
39
|
+
|
|
40
|
+
<div style="display: none" aria-hidden="true">
|
|
41
|
+
<div bind:this={content} class={['maplibregl-ctrl', className]}>
|
|
42
|
+
{#if context.map}
|
|
43
|
+
{@render children({ map: context.map })}
|
|
44
|
+
{/if}
|
|
45
|
+
</div>
|
|
46
|
+
</div>
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { ControlPosition, Map as MapLibreMap } from 'maplibre-gl';
|
|
2
|
+
import type { Snippet } from 'svelte';
|
|
3
|
+
type Props = {
|
|
4
|
+
/** @defaultValue 'top-right' */
|
|
5
|
+
position?: ControlPosition;
|
|
6
|
+
class?: string;
|
|
7
|
+
children: Snippet<[{
|
|
8
|
+
map: MapLibreMap;
|
|
9
|
+
}]>;
|
|
10
|
+
};
|
|
11
|
+
declare const CustomControl: import("svelte").Component<Props, {}, "">;
|
|
12
|
+
type CustomControl = ReturnType<typeof CustomControl>;
|
|
13
|
+
export default CustomControl;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { FullscreenControl as MapLibreFullscreenControl } from 'maplibre-gl';
|
|
3
|
+
import type {
|
|
4
|
+
ControlPosition,
|
|
5
|
+
FullscreenControlEventType,
|
|
6
|
+
FullscreenControlOptions
|
|
7
|
+
} from 'maplibre-gl';
|
|
8
|
+
import { splitEventProps } from '../../internal/events.js';
|
|
9
|
+
import type { EventProps } from '../../types.js';
|
|
10
|
+
import Control from './Control.svelte';
|
|
11
|
+
|
|
12
|
+
type Props = FullscreenControlOptions &
|
|
13
|
+
EventProps<FullscreenControlEventType> & {
|
|
14
|
+
/** @defaultValue 'top-right' */
|
|
15
|
+
position?: ControlPosition;
|
|
16
|
+
/** Read-only binding to the underlying control, for imperative calls. */
|
|
17
|
+
control?: MapLibreFullscreenControl | null;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
let { position = 'top-right', control = $bindable(null), ...props }: Props = $props();
|
|
21
|
+
|
|
22
|
+
// Handlers must not reach the constructor as if they were options.
|
|
23
|
+
const split = $derived(splitEventProps(props));
|
|
24
|
+
</script>
|
|
25
|
+
|
|
26
|
+
<Control
|
|
27
|
+
factory={(resolved: FullscreenControlOptions) => new MapLibreFullscreenControl(resolved)}
|
|
28
|
+
options={split.rest as FullscreenControlOptions}
|
|
29
|
+
{position}
|
|
30
|
+
bind:control
|
|
31
|
+
{...split.events}
|
|
32
|
+
/>
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { FullscreenControl as MapLibreFullscreenControl } from 'maplibre-gl';
|
|
2
|
+
import type { ControlPosition, FullscreenControlEventType, FullscreenControlOptions } from 'maplibre-gl';
|
|
3
|
+
import type { EventProps } from '../../types.js';
|
|
4
|
+
type Props = FullscreenControlOptions & EventProps<FullscreenControlEventType> & {
|
|
5
|
+
/** @defaultValue 'top-right' */
|
|
6
|
+
position?: ControlPosition;
|
|
7
|
+
/** Read-only binding to the underlying control, for imperative calls. */
|
|
8
|
+
control?: MapLibreFullscreenControl | null;
|
|
9
|
+
};
|
|
10
|
+
declare const FullscreenControl: import("svelte").Component<Props, {}, "control">;
|
|
11
|
+
type FullscreenControl = ReturnType<typeof FullscreenControl>;
|
|
12
|
+
export default FullscreenControl;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { GeolocateControl as MapLibreGeolocateControl } from 'maplibre-gl';
|
|
3
|
+
import type {
|
|
4
|
+
ControlPosition,
|
|
5
|
+
GeolocateControlEventType,
|
|
6
|
+
GeolocateControlOptions
|
|
7
|
+
} from 'maplibre-gl';
|
|
8
|
+
import { splitEventProps } from '../../internal/events.js';
|
|
9
|
+
import type { EventProps } from '../../types.js';
|
|
10
|
+
import Control from './Control.svelte';
|
|
11
|
+
|
|
12
|
+
type Props = GeolocateControlOptions &
|
|
13
|
+
EventProps<GeolocateControlEventType> & {
|
|
14
|
+
/** @defaultValue 'top-right' */
|
|
15
|
+
position?: ControlPosition;
|
|
16
|
+
/** Read-only binding to the underlying control, for imperative calls. */
|
|
17
|
+
control?: MapLibreGeolocateControl | null;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
let { position = 'top-right', control = $bindable(null), ...props }: Props = $props();
|
|
21
|
+
|
|
22
|
+
// Handlers must not reach the constructor as if they were options.
|
|
23
|
+
const split = $derived(splitEventProps(props));
|
|
24
|
+
</script>
|
|
25
|
+
|
|
26
|
+
<Control
|
|
27
|
+
factory={(resolved: GeolocateControlOptions) => new MapLibreGeolocateControl(resolved)}
|
|
28
|
+
options={split.rest as GeolocateControlOptions}
|
|
29
|
+
{position}
|
|
30
|
+
bind:control
|
|
31
|
+
{...split.events}
|
|
32
|
+
/>
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { GeolocateControl as MapLibreGeolocateControl } from 'maplibre-gl';
|
|
2
|
+
import type { ControlPosition, GeolocateControlEventType, GeolocateControlOptions } from 'maplibre-gl';
|
|
3
|
+
import type { EventProps } from '../../types.js';
|
|
4
|
+
type Props = GeolocateControlOptions & EventProps<GeolocateControlEventType> & {
|
|
5
|
+
/** @defaultValue 'top-right' */
|
|
6
|
+
position?: ControlPosition;
|
|
7
|
+
/** Read-only binding to the underlying control, for imperative calls. */
|
|
8
|
+
control?: MapLibreGeolocateControl | null;
|
|
9
|
+
};
|
|
10
|
+
declare const GeolocateControl: import("svelte").Component<Props, {}, "control">;
|
|
11
|
+
type GeolocateControl = ReturnType<typeof GeolocateControl>;
|
|
12
|
+
export default GeolocateControl;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { GlobeControl as MapLibreGlobeControl } from 'maplibre-gl';
|
|
3
|
+
import type { ControlPosition } from 'maplibre-gl';
|
|
4
|
+
import Control from './Control.svelte';
|
|
5
|
+
|
|
6
|
+
type Props = {
|
|
7
|
+
/** @defaultValue 'top-right' */
|
|
8
|
+
position?: ControlPosition;
|
|
9
|
+
/** Read-only binding to the underlying control, for imperative calls. */
|
|
10
|
+
control?: MapLibreGlobeControl | null;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
let { position = 'top-right', control = $bindable(null) }: Props = $props();
|
|
14
|
+
</script>
|
|
15
|
+
|
|
16
|
+
<Control factory={() => new MapLibreGlobeControl()} options={undefined} {position} bind:control />
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { GlobeControl as MapLibreGlobeControl } from 'maplibre-gl';
|
|
2
|
+
import type { ControlPosition } from 'maplibre-gl';
|
|
3
|
+
type Props = {
|
|
4
|
+
/** @defaultValue 'top-right' */
|
|
5
|
+
position?: ControlPosition;
|
|
6
|
+
/** Read-only binding to the underlying control, for imperative calls. */
|
|
7
|
+
control?: MapLibreGlobeControl | null;
|
|
8
|
+
};
|
|
9
|
+
declare const GlobeControl: import("svelte").Component<Props, {}, "control">;
|
|
10
|
+
type GlobeControl = ReturnType<typeof GlobeControl>;
|
|
11
|
+
export default GlobeControl;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { LogoControl as MapLibreLogoControl } from 'maplibre-gl';
|
|
3
|
+
import type { ControlPosition, LogoControlOptions } from 'maplibre-gl';
|
|
4
|
+
import Control from './Control.svelte';
|
|
5
|
+
|
|
6
|
+
type Props = LogoControlOptions & {
|
|
7
|
+
/** @defaultValue 'top-right' */
|
|
8
|
+
position?: ControlPosition;
|
|
9
|
+
/** Read-only binding to the underlying control, for imperative calls. */
|
|
10
|
+
control?: MapLibreLogoControl | null;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
let { position = 'top-right', control = $bindable(null), ...options }: Props = $props();
|
|
14
|
+
</script>
|
|
15
|
+
|
|
16
|
+
<Control
|
|
17
|
+
factory={(resolved: LogoControlOptions) => new MapLibreLogoControl(resolved)}
|
|
18
|
+
{options}
|
|
19
|
+
{position}
|
|
20
|
+
bind:control
|
|
21
|
+
/>
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { LogoControl as MapLibreLogoControl } from 'maplibre-gl';
|
|
2
|
+
import type { ControlPosition, LogoControlOptions } from 'maplibre-gl';
|
|
3
|
+
type Props = LogoControlOptions & {
|
|
4
|
+
/** @defaultValue 'top-right' */
|
|
5
|
+
position?: ControlPosition;
|
|
6
|
+
/** Read-only binding to the underlying control, for imperative calls. */
|
|
7
|
+
control?: MapLibreLogoControl | null;
|
|
8
|
+
};
|
|
9
|
+
declare const LogoControl: import("svelte").Component<Props, {}, "control">;
|
|
10
|
+
type LogoControl = ReturnType<typeof LogoControl>;
|
|
11
|
+
export default LogoControl;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { NavigationControl as MapLibreNavigationControl } from 'maplibre-gl';
|
|
3
|
+
import type { ControlPosition, NavigationControlOptions } from 'maplibre-gl';
|
|
4
|
+
import Control from './Control.svelte';
|
|
5
|
+
|
|
6
|
+
type Props = NavigationControlOptions & {
|
|
7
|
+
/** @defaultValue 'top-right' */
|
|
8
|
+
position?: ControlPosition;
|
|
9
|
+
/** Read-only binding to the underlying control, for imperative calls. */
|
|
10
|
+
control?: MapLibreNavigationControl | null;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
let { position = 'top-right', control = $bindable(null), ...options }: Props = $props();
|
|
14
|
+
</script>
|
|
15
|
+
|
|
16
|
+
<Control
|
|
17
|
+
factory={(resolved: NavigationControlOptions) => new MapLibreNavigationControl(resolved)}
|
|
18
|
+
{options}
|
|
19
|
+
{position}
|
|
20
|
+
bind:control
|
|
21
|
+
/>
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { NavigationControl as MapLibreNavigationControl } from 'maplibre-gl';
|
|
2
|
+
import type { ControlPosition, NavigationControlOptions } from 'maplibre-gl';
|
|
3
|
+
type Props = NavigationControlOptions & {
|
|
4
|
+
/** @defaultValue 'top-right' */
|
|
5
|
+
position?: ControlPosition;
|
|
6
|
+
/** Read-only binding to the underlying control, for imperative calls. */
|
|
7
|
+
control?: MapLibreNavigationControl | null;
|
|
8
|
+
};
|
|
9
|
+
declare const NavigationControl: import("svelte").Component<Props, {}, "control">;
|
|
10
|
+
type NavigationControl = ReturnType<typeof NavigationControl>;
|
|
11
|
+
export default NavigationControl;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { ScaleControl as MapLibreScaleControl } from 'maplibre-gl';
|
|
3
|
+
import type { ControlPosition, ScaleControlOptions } from 'maplibre-gl';
|
|
4
|
+
import Control from './Control.svelte';
|
|
5
|
+
|
|
6
|
+
type Props = ScaleControlOptions & {
|
|
7
|
+
/** @defaultValue 'top-right' */
|
|
8
|
+
position?: ControlPosition;
|
|
9
|
+
/** Read-only binding to the underlying control, for imperative calls. */
|
|
10
|
+
control?: MapLibreScaleControl | null;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
let { position = 'top-right', control = $bindable(null), ...options }: Props = $props();
|
|
14
|
+
</script>
|
|
15
|
+
|
|
16
|
+
<Control
|
|
17
|
+
factory={(resolved: ScaleControlOptions) => new MapLibreScaleControl(resolved)}
|
|
18
|
+
{options}
|
|
19
|
+
{position}
|
|
20
|
+
bind:control
|
|
21
|
+
/>
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ScaleControl as MapLibreScaleControl } from 'maplibre-gl';
|
|
2
|
+
import type { ControlPosition, ScaleControlOptions } from 'maplibre-gl';
|
|
3
|
+
type Props = ScaleControlOptions & {
|
|
4
|
+
/** @defaultValue 'top-right' */
|
|
5
|
+
position?: ControlPosition;
|
|
6
|
+
/** Read-only binding to the underlying control, for imperative calls. */
|
|
7
|
+
control?: MapLibreScaleControl | null;
|
|
8
|
+
};
|
|
9
|
+
declare const ScaleControl: import("svelte").Component<Props, {}, "control">;
|
|
10
|
+
type ScaleControl = ReturnType<typeof ScaleControl>;
|
|
11
|
+
export default ScaleControl;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { TerrainControl as MapLibreTerrainControl } from 'maplibre-gl';
|
|
3
|
+
import type { ControlPosition, TerrainSpecification } from 'maplibre-gl';
|
|
4
|
+
import Control from './Control.svelte';
|
|
5
|
+
|
|
6
|
+
type Props = TerrainSpecification & {
|
|
7
|
+
/** @defaultValue 'top-right' */
|
|
8
|
+
position?: ControlPosition;
|
|
9
|
+
/** Read-only binding to the underlying control, for imperative calls. */
|
|
10
|
+
control?: MapLibreTerrainControl | null;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
let { position = 'top-right', control = $bindable(null), ...options }: Props = $props();
|
|
14
|
+
</script>
|
|
15
|
+
|
|
16
|
+
<Control
|
|
17
|
+
factory={(resolved: TerrainSpecification) => new MapLibreTerrainControl(resolved)}
|
|
18
|
+
{options}
|
|
19
|
+
{position}
|
|
20
|
+
bind:control
|
|
21
|
+
/>
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { TerrainControl as MapLibreTerrainControl } from 'maplibre-gl';
|
|
2
|
+
import type { ControlPosition, TerrainSpecification } from 'maplibre-gl';
|
|
3
|
+
type Props = TerrainSpecification & {
|
|
4
|
+
/** @defaultValue 'top-right' */
|
|
5
|
+
position?: ControlPosition;
|
|
6
|
+
/** Read-only binding to the underlying control, for imperative calls. */
|
|
7
|
+
control?: MapLibreTerrainControl | null;
|
|
8
|
+
};
|
|
9
|
+
declare const TerrainControl: import("svelte").Component<Props, {}, "control">;
|
|
10
|
+
type TerrainControl = ReturnType<typeof TerrainControl>;
|
|
11
|
+
export default TerrainControl;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { untrack } from 'svelte';
|
|
3
|
+
import { getMapContext, getSourceContext } from '../../context.js';
|
|
4
|
+
import { isStyleAlive } from '../../internal/style-ops.js';
|
|
5
|
+
|
|
6
|
+
type Props = {
|
|
7
|
+
/** Defaults to the id of the enclosing source component. */
|
|
8
|
+
source?: string;
|
|
9
|
+
/** Required for vector tile sources with more than one layer. */
|
|
10
|
+
sourceLayer?: string;
|
|
11
|
+
/** The feature id. Vector features need `promoteId` if their id is a property. */
|
|
12
|
+
id: string | number;
|
|
13
|
+
/** Read from style expressions through `["feature-state", key]`. */
|
|
14
|
+
state: Record<string, unknown>;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
let { source, sourceLayer, id, state }: Props = $props();
|
|
18
|
+
|
|
19
|
+
const context = getMapContext();
|
|
20
|
+
const sourceContext = getSourceContext();
|
|
21
|
+
const resolvedSource = $derived(source ?? sourceContext?.id);
|
|
22
|
+
|
|
23
|
+
// Declarative hover and selection: mount the component while a feature is
|
|
24
|
+
// active and remove it when it is not, instead of pairing every
|
|
25
|
+
// setFeatureState call with a matching removeFeatureState by hand.
|
|
26
|
+
$effect(() => {
|
|
27
|
+
const map = context.map;
|
|
28
|
+
const ready = context.ready;
|
|
29
|
+
void context.styleEpoch;
|
|
30
|
+
void sourceContext?.epoch;
|
|
31
|
+
|
|
32
|
+
const sourceId = resolvedSource;
|
|
33
|
+
const featureId = id;
|
|
34
|
+
const next = state;
|
|
35
|
+
|
|
36
|
+
if (!map || !ready) return;
|
|
37
|
+
|
|
38
|
+
if (!sourceId) {
|
|
39
|
+
throw new Error(
|
|
40
|
+
'[maplibrex] <FeatureState> needs a source: pass `source` or nest it inside a source component.'
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const target = {
|
|
45
|
+
source: sourceId,
|
|
46
|
+
id: featureId,
|
|
47
|
+
...(sourceLayer ? { sourceLayer } : {})
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
untrack(() => map.setFeatureState(target, next));
|
|
51
|
+
|
|
52
|
+
return () => {
|
|
53
|
+
if (isStyleAlive(map)) map.removeFeatureState(target);
|
|
54
|
+
};
|
|
55
|
+
});
|
|
56
|
+
</script>
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
type Props = {
|
|
2
|
+
/** Defaults to the id of the enclosing source component. */
|
|
3
|
+
source?: string;
|
|
4
|
+
/** Required for vector tile sources with more than one layer. */
|
|
5
|
+
sourceLayer?: string;
|
|
6
|
+
/** The feature id. Vector features need `promoteId` if their id is a property. */
|
|
7
|
+
id: string | number;
|
|
8
|
+
/** Read from style expressions through `["feature-state", key]`. */
|
|
9
|
+
state: Record<string, unknown>;
|
|
10
|
+
};
|
|
11
|
+
declare const FeatureState: import("svelte").Component<Props, {}, "">;
|
|
12
|
+
type FeatureState = ReturnType<typeof FeatureState>;
|
|
13
|
+
export default FeatureState;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { addProtocol, removeProtocol } from 'maplibre-gl';
|
|
3
|
+
import type { AddProtocolAction } from 'maplibre-gl';
|
|
4
|
+
|
|
5
|
+
type Props = {
|
|
6
|
+
/** The scheme to claim, without `://` — for example `pmtiles`. */
|
|
7
|
+
name: string;
|
|
8
|
+
handler: AddProtocolAction;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
let { name, handler }: Props = $props();
|
|
12
|
+
|
|
13
|
+
// Protocols are global to MapLibre, not scoped to one map, so this component
|
|
14
|
+
// needs no map context. Ordering does matter: register the protocol BEFORE the
|
|
15
|
+
// map that requests those URLs, by placing this component above <MapLibre>.
|
|
16
|
+
$effect(() => {
|
|
17
|
+
const scheme = name;
|
|
18
|
+
const load = handler;
|
|
19
|
+
|
|
20
|
+
addProtocol(scheme, load);
|
|
21
|
+
|
|
22
|
+
return () => removeProtocol(scheme);
|
|
23
|
+
});
|
|
24
|
+
</script>
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { AddProtocolAction } from 'maplibre-gl';
|
|
2
|
+
type Props = {
|
|
3
|
+
/** The scheme to claim, without `://` — for example `pmtiles`. */
|
|
4
|
+
name: string;
|
|
5
|
+
handler: AddProtocolAction;
|
|
6
|
+
};
|
|
7
|
+
declare const Protocol: import("svelte").Component<Props, {}, "">;
|
|
8
|
+
type Protocol = ReturnType<typeof Protocol>;
|
|
9
|
+
export default Protocol;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { BackgroundLayerSpecification } from 'maplibre-gl';
|
|
3
|
+
import type { Snippet } from 'svelte';
|
|
4
|
+
import Layer from './Layer.svelte';
|
|
5
|
+
import type { LayerEventProps } from '../../types.js';
|
|
6
|
+
|
|
7
|
+
type Props = Omit<BackgroundLayerSpecification, 'type' | 'id'> &
|
|
8
|
+
LayerEventProps & {
|
|
9
|
+
/** Unique within the style. Changing it recreates the layer. */
|
|
10
|
+
id: string;
|
|
11
|
+
/** Insert before this layer id; changing it moves the layer. */
|
|
12
|
+
beforeId?: string;
|
|
13
|
+
/** Sugar over `layout.visibility`. @defaultValue true */
|
|
14
|
+
visible?: boolean;
|
|
15
|
+
children?: Snippet<[{ id: string }]>;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
let props: Props = $props();
|
|
19
|
+
</script>
|
|
20
|
+
|
|
21
|
+
<Layer type="background" {...props} />
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { BackgroundLayerSpecification } from 'maplibre-gl';
|
|
2
|
+
import type { Snippet } from 'svelte';
|
|
3
|
+
import type { LayerEventProps } from '../../types.js';
|
|
4
|
+
type Props = Omit<BackgroundLayerSpecification, 'type' | 'id'> & LayerEventProps & {
|
|
5
|
+
/** Unique within the style. Changing it recreates the layer. */
|
|
6
|
+
id: string;
|
|
7
|
+
/** Insert before this layer id; changing it moves the layer. */
|
|
8
|
+
beforeId?: string;
|
|
9
|
+
/** Sugar over `layout.visibility`. @defaultValue true */
|
|
10
|
+
visible?: boolean;
|
|
11
|
+
children?: Snippet<[{
|
|
12
|
+
id: string;
|
|
13
|
+
}]>;
|
|
14
|
+
};
|
|
15
|
+
declare const BackgroundLayer: import("svelte").Component<Props, {}, "">;
|
|
16
|
+
type BackgroundLayer = ReturnType<typeof BackgroundLayer>;
|
|
17
|
+
export default BackgroundLayer;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { CircleLayerSpecification } from 'maplibre-gl';
|
|
3
|
+
import type { Snippet } from 'svelte';
|
|
4
|
+
import Layer from './Layer.svelte';
|
|
5
|
+
import type { LayerEventProps } from '../../types.js';
|
|
6
|
+
|
|
7
|
+
type Props = Omit<CircleLayerSpecification, 'type' | 'id' | 'source' | 'source-layer'> &
|
|
8
|
+
LayerEventProps & {
|
|
9
|
+
/** Unique within the style. Changing it recreates the layer. */
|
|
10
|
+
id: string;
|
|
11
|
+
/** Defaults to the id of the enclosing source component. */
|
|
12
|
+
source?: string;
|
|
13
|
+
/** Required for vector tile sources with more than one layer. */
|
|
14
|
+
sourceLayer?: string;
|
|
15
|
+
/** Insert before this layer id; changing it moves the layer. */
|
|
16
|
+
beforeId?: string;
|
|
17
|
+
/** Sugar over `layout.visibility`. @defaultValue true */
|
|
18
|
+
visible?: boolean;
|
|
19
|
+
children?: Snippet<[{ id: string }]>;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
let props: Props = $props();
|
|
23
|
+
</script>
|
|
24
|
+
|
|
25
|
+
<Layer type="circle" {...props} />
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { CircleLayerSpecification } from 'maplibre-gl';
|
|
2
|
+
import type { Snippet } from 'svelte';
|
|
3
|
+
import type { LayerEventProps } from '../../types.js';
|
|
4
|
+
type Props = Omit<CircleLayerSpecification, 'type' | 'id' | 'source' | 'source-layer'> & LayerEventProps & {
|
|
5
|
+
/** Unique within the style. Changing it recreates the layer. */
|
|
6
|
+
id: string;
|
|
7
|
+
/** Defaults to the id of the enclosing source component. */
|
|
8
|
+
source?: string;
|
|
9
|
+
/** Required for vector tile sources with more than one layer. */
|
|
10
|
+
sourceLayer?: string;
|
|
11
|
+
/** Insert before this layer id; changing it moves the layer. */
|
|
12
|
+
beforeId?: string;
|
|
13
|
+
/** Sugar over `layout.visibility`. @defaultValue true */
|
|
14
|
+
visible?: boolean;
|
|
15
|
+
children?: Snippet<[{
|
|
16
|
+
id: string;
|
|
17
|
+
}]>;
|
|
18
|
+
};
|
|
19
|
+
declare const CircleLayer: import("svelte").Component<Props, {}, "">;
|
|
20
|
+
type CircleLayer = ReturnType<typeof CircleLayer>;
|
|
21
|
+
export default CircleLayer;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { ColorReliefLayerSpecification } from 'maplibre-gl';
|
|
3
|
+
import type { Snippet } from 'svelte';
|
|
4
|
+
import Layer from './Layer.svelte';
|
|
5
|
+
import type { LayerEventProps } from '../../types.js';
|
|
6
|
+
|
|
7
|
+
type Props = Omit<ColorReliefLayerSpecification, 'type' | 'id' | 'source' | 'source-layer'> &
|
|
8
|
+
LayerEventProps & {
|
|
9
|
+
/** Unique within the style. Changing it recreates the layer. */
|
|
10
|
+
id: string;
|
|
11
|
+
/** Defaults to the id of the enclosing source component. */
|
|
12
|
+
source?: string;
|
|
13
|
+
/** Required for vector tile sources with more than one layer. */
|
|
14
|
+
sourceLayer?: string;
|
|
15
|
+
/** Insert before this layer id; changing it moves the layer. */
|
|
16
|
+
beforeId?: string;
|
|
17
|
+
/** Sugar over `layout.visibility`. @defaultValue true */
|
|
18
|
+
visible?: boolean;
|
|
19
|
+
children?: Snippet<[{ id: string }]>;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
let props: Props = $props();
|
|
23
|
+
</script>
|
|
24
|
+
|
|
25
|
+
<Layer type="color-relief" {...props} />
|