@swr-data-lab/components 2.0.0 → 2.2.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/dist/maplibre/GeoJSONSource/GeoJSONSource.svelte +13 -0
- package/dist/maplibre/GeoJSONSource/GeoJSONSource.svelte.d.ts +15 -0
- package/dist/maplibre/GeoJSONSource/index.d.ts +2 -0
- package/dist/maplibre/GeoJSONSource/index.js +2 -0
- package/dist/maplibre/Map/Map.svelte +12 -3
- package/dist/maplibre/Map/Map.svelte.d.ts +6 -2
- package/dist/maplibre/VectorLayer/VectorLayer.svelte +1 -1
- package/dist/maplibre/VectorLayer/VectorLayer.svelte.d.ts +1 -1
- package/dist/maplibre/VectorTileSource/VectorTileSource.svelte +4 -4
- package/dist/maplibre/VectorTileSource/VectorTileSource.svelte.d.ts +4 -2
- package/package.json +3 -2
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
<script lang="ts">// See: https://maplibre.org/maplibre-gl-js/docs/API/classes/GeoJSONSource/
|
|
2
|
+
import {} from 'maplibre-gl';
|
|
3
|
+
import MapSource from '../Source/MapSource.svelte';
|
|
4
|
+
const { maxZoom = 24, id, data, attribution = '' } = $props();
|
|
5
|
+
const sourceSpec = {
|
|
6
|
+
type: 'geojson',
|
|
7
|
+
data,
|
|
8
|
+
maxzoom: maxZoom,
|
|
9
|
+
attribution
|
|
10
|
+
};
|
|
11
|
+
</script>
|
|
12
|
+
|
|
13
|
+
<MapSource {id} {sourceSpec} />
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
interface GeoJSONSourceProps {
|
|
2
|
+
id: string;
|
|
3
|
+
/**
|
|
4
|
+
* GeoJSON object or URL
|
|
5
|
+
*/
|
|
6
|
+
data: GeoJSON.GeoJSON | string;
|
|
7
|
+
/**
|
|
8
|
+
* Attribution string for your data, usually rendered using an `<AttributionControl>`
|
|
9
|
+
*/
|
|
10
|
+
attribution?: string;
|
|
11
|
+
maxZoom?: number;
|
|
12
|
+
}
|
|
13
|
+
declare const GeoJsonSource: import("svelte").Component<GeoJSONSourceProps, {}, "">;
|
|
14
|
+
type GeoJsonSource = ReturnType<typeof GeoJsonSource>;
|
|
15
|
+
export default GeoJsonSource;
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
<script lang="ts">import maplibre, {} from 'maplibre-gl';
|
|
2
2
|
import { onMount, onDestroy, getContext, hasContext } from 'svelte';
|
|
3
|
-
import { createMapContext } from '../context.svelte.js';
|
|
3
|
+
import { createMapContext, MapContext } from '../context.svelte.js';
|
|
4
4
|
import {} from '../types';
|
|
5
5
|
import FallbackStyle from './FallbackStyle';
|
|
6
|
-
let { children, options, style = FallbackStyle, minZoom = 0, maxZoom = 14.99, zoom = $bindable(), center = $bindable(), pitch = $bindable(0), bearing = $bindable(0), loading = $bindable(true), projection = { type: 'mercator' }, allowRotation = false, allowZoom = true, showDebug = false, initialLocation: receivedInitialLocation
|
|
6
|
+
let { children, options, style = FallbackStyle, minZoom = 0, maxZoom = 14.99, zoom = $bindable(), center = $bindable(), pitch = $bindable(0), bearing = $bindable(0), loading = $bindable(true), projection = { type: 'mercator' }, allowRotation = false, allowZoom = true, showDebug = false, initialLocation: receivedInitialLocation,
|
|
7
|
+
// Future: This should become bindable.readonly when that becomes
|
|
8
|
+
// available, see: https://github.com/sveltejs/svelte/issues/7712
|
|
9
|
+
mapContext = $bindable(), onmoveend, onmovestart } = $props();
|
|
7
10
|
let container;
|
|
8
11
|
// Merge initial location with default object so individual
|
|
9
12
|
// properties (like pitch) can be omitted by the caller
|
|
@@ -14,7 +17,7 @@ let initialLocation = {
|
|
|
14
17
|
pitch: 0,
|
|
15
18
|
...receivedInitialLocation
|
|
16
19
|
};
|
|
17
|
-
|
|
20
|
+
mapContext = createMapContext();
|
|
18
21
|
if (getContext('initialLocation') !== undefined && getContext('initialLocation') !== false) {
|
|
19
22
|
initialLocation = getContext('initialLocation');
|
|
20
23
|
}
|
|
@@ -43,6 +46,12 @@ onMount(() => {
|
|
|
43
46
|
pitch = mapContext.map?.getPitch();
|
|
44
47
|
bearing = mapContext.map?.getBearing();
|
|
45
48
|
});
|
|
49
|
+
if (onmoveend) {
|
|
50
|
+
mapContext.map.on('moveend', onmoveend);
|
|
51
|
+
}
|
|
52
|
+
if (onmovestart) {
|
|
53
|
+
mapContext.map.on('movestart', onmovestart);
|
|
54
|
+
}
|
|
46
55
|
});
|
|
47
56
|
onDestroy(async () => {
|
|
48
57
|
if (mapContext.map)
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import maplibre, { type ProjectionSpecification, type StyleSpecification } from 'maplibre-gl';
|
|
1
|
+
import maplibre, { type MapLibreEvent, type ProjectionSpecification, type StyleSpecification } from 'maplibre-gl';
|
|
2
2
|
import { type Snippet } from 'svelte';
|
|
3
|
+
import { MapContext } from '../context.svelte.js';
|
|
3
4
|
import { type Location } from '../types';
|
|
4
5
|
interface MapProps {
|
|
5
6
|
style?: StyleSpecification | string;
|
|
@@ -16,8 +17,11 @@ interface MapProps {
|
|
|
16
17
|
projection?: ProjectionSpecification;
|
|
17
18
|
showDebug?: boolean;
|
|
18
19
|
options?: any;
|
|
20
|
+
mapContext?: MapContext;
|
|
21
|
+
onmovestart?: (e: MapLibreEvent) => null;
|
|
22
|
+
onmoveend?: (e: MapLibreEvent) => null;
|
|
19
23
|
children?: Snippet;
|
|
20
24
|
}
|
|
21
|
-
declare const Map: import("svelte").Component<MapProps, {}, "center" | "zoom" | "pitch" | "bearing" | "loading">;
|
|
25
|
+
declare const Map: import("svelte").Component<MapProps, {}, "center" | "zoom" | "pitch" | "bearing" | "loading" | "mapContext">;
|
|
22
26
|
type Map = ReturnType<typeof Map>;
|
|
23
27
|
export default Map;
|
|
@@ -2,7 +2,7 @@ import type { CircleLayoutProps, CirclePaintProps, FillLayoutProps, FillPaintPro
|
|
|
2
2
|
interface VectorLayerProps {
|
|
3
3
|
id: string;
|
|
4
4
|
sourceId: string;
|
|
5
|
-
sourceLayer
|
|
5
|
+
sourceLayer?: string;
|
|
6
6
|
type: 'line' | 'fill' | 'circle' | 'symbol';
|
|
7
7
|
placeBelow: string;
|
|
8
8
|
visible?: boolean;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
<script lang="ts">import {} from '
|
|
2
|
-
import {} from 'maplibre-gl';
|
|
1
|
+
<script lang="ts">import {} from 'maplibre-gl';
|
|
3
2
|
import MapSource from '../Source/MapSource.svelte';
|
|
4
|
-
const { minZoom = 0, maxZoom = 24, id, url } = $props();
|
|
3
|
+
const { minZoom = 0, maxZoom = 24, id, url, attribution = '' } = $props();
|
|
5
4
|
const sourceSpec = {
|
|
6
5
|
type: 'vector',
|
|
7
6
|
tiles: [url],
|
|
8
7
|
maxzoom: maxZoom,
|
|
9
|
-
minzoom: minZoom
|
|
8
|
+
minzoom: minZoom,
|
|
9
|
+
attribution
|
|
10
10
|
};
|
|
11
11
|
</script>
|
|
12
12
|
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import { type Snippet } from 'svelte';
|
|
2
1
|
interface VectorTileSourceProps {
|
|
3
2
|
id: string;
|
|
4
3
|
url: string;
|
|
5
4
|
minZoom?: number;
|
|
6
5
|
maxZoom?: number;
|
|
7
|
-
|
|
6
|
+
/**
|
|
7
|
+
* Attribution string for your data, usually rendered using an `<AttributionControl>`
|
|
8
|
+
*/
|
|
9
|
+
attribution?: string;
|
|
8
10
|
}
|
|
9
11
|
declare const VectorTileSource: import("svelte").Component<VectorTileSourceProps, {}, "">;
|
|
10
12
|
type VectorTileSource = ReturnType<typeof VectorTileSource>;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@swr-data-lab/components",
|
|
3
3
|
"description": "SWR Data Lab component library",
|
|
4
|
-
"version": "2.
|
|
4
|
+
"version": "2.2.0",
|
|
5
5
|
"author": "SWR Data Lab",
|
|
6
6
|
"license": "UNLICENSED",
|
|
7
7
|
"type": "module",
|
|
@@ -49,6 +49,7 @@
|
|
|
49
49
|
"@sveltejs/kit": "^2.22.2",
|
|
50
50
|
"@sveltejs/package": "^2.3.12",
|
|
51
51
|
"@sveltejs/vite-plugin-svelte": "^5.1.0",
|
|
52
|
+
"@types/geojson": "^7946.0.16",
|
|
52
53
|
"@versatiles/style": "^5.6.0",
|
|
53
54
|
"@vitest/browser": "^3.2.4",
|
|
54
55
|
"@vitest/coverage-v8": "^3.2.4",
|
|
@@ -61,9 +62,9 @@
|
|
|
61
62
|
"sass-embedded": "^1.89.2",
|
|
62
63
|
"semantic-release": "^24.2.6",
|
|
63
64
|
"storybook": "^9.0.15",
|
|
64
|
-
"svelte-preprocess": "^6.0.3",
|
|
65
65
|
"svelte": "^5.23.0",
|
|
66
66
|
"svelte-check": "^4.0.0",
|
|
67
|
+
"svelte-preprocess": "^6.0.3",
|
|
67
68
|
"typescript": "^5.8.3",
|
|
68
69
|
"vite": "^6.0.0",
|
|
69
70
|
"vitest": "^3.1.1",
|