@classic-homes/maps-svelte 0.6.1 → 0.7.1
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 +18 -2
- package/dist/lib/components/controls/BasemapSwitcher.svelte +1 -1
- package/dist/lib/components/controls/CoordinateDisplay.svelte +1 -1
- package/dist/lib/components/controls/LayerManager.svelte +13 -3
- package/dist/lib/components/core/Map.svelte +6 -1
- package/dist/lib/components/core/Marker.svelte +1 -1
- package/dist/lib/components/core/Popup.svelte +1 -1
- package/dist/lib/components/core/Source.svelte +1 -1
- package/dist/lib/components/deck/DeckOverlay.svelte +1 -1
- package/dist/lib/components/layers/useLayer.svelte.d.ts +1 -1
- package/dist/lib/composables/useMapContext.svelte.d.ts +1 -1
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -8,6 +8,22 @@ Svelte 5 components for MapLibre GL maps in the Classic Theme design system.
|
|
|
8
8
|
npm install @classic-homes/maps-svelte maplibre-gl
|
|
9
9
|
```
|
|
10
10
|
|
|
11
|
+
### MapLibre 6: set the worker URL
|
|
12
|
+
|
|
13
|
+
MapLibre 6 loads its tile worker from a separate file, which it cannot find on
|
|
14
|
+
its own under a bundler. Set the URL once at app startup, before the first map
|
|
15
|
+
renders; without it every map fails with "Worker failed to load".
|
|
16
|
+
|
|
17
|
+
```ts
|
|
18
|
+
import { setWorkerUrl } from 'maplibre-gl';
|
|
19
|
+
import workerUrl from 'maplibre-gl/dist/maplibre-gl-worker.mjs?worker&url'; // Vite
|
|
20
|
+
|
|
21
|
+
setWorkerUrl(workerUrl);
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
With webpack: `setWorkerUrl(new URL('maplibre-gl/dist/maplibre-gl-worker.mjs', import.meta.url).toString())`.
|
|
25
|
+
MapLibre 5 bundles its worker and needs none of this.
|
|
26
|
+
|
|
11
27
|
## Features
|
|
12
28
|
|
|
13
29
|
- **Svelte 5 Runes**: Modern `$state`, `$derived`, `$effect` patterns
|
|
@@ -424,8 +440,8 @@ import type {
|
|
|
424
440
|
|
|
425
441
|
## Peer Dependencies
|
|
426
442
|
|
|
427
|
-
- `svelte`
|
|
428
|
-
- `maplibre-gl`
|
|
443
|
+
- `svelte` ^5.31.0
|
|
444
|
+
- `maplibre-gl` ^5.0.0 || ^6.11.0
|
|
429
445
|
|
|
430
446
|
## License
|
|
431
447
|
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
} from '@classic-homes/maps-core';
|
|
11
11
|
import '@classic-homes/maps-core/styles/basemap-switcher.css';
|
|
12
12
|
import { cn } from '../../utils.js';
|
|
13
|
-
import type maplibregl from 'maplibre-gl';
|
|
13
|
+
import type * as maplibregl from 'maplibre-gl';
|
|
14
14
|
import { useControlPosition } from '../../composables/useControlPosition.svelte.js';
|
|
15
15
|
|
|
16
16
|
interface MapContext {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import { getContext } from 'svelte';
|
|
3
|
-
import type maplibregl from 'maplibre-gl';
|
|
3
|
+
import type * as maplibregl from 'maplibre-gl';
|
|
4
4
|
import type { CoordinateDisplayProps, LngLat } from '@classic-homes/maps-core';
|
|
5
5
|
import { formatCoordinates, EDGE_MARGIN, STACK_GAP } from '@classic-homes/maps-core';
|
|
6
6
|
import { cn } from '../../utils.js';
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
import '@classic-homes/maps-core/styles/layer-manager.css';
|
|
19
19
|
import { Switch } from '@classic-homes/theme-svelte';
|
|
20
20
|
import { cn } from '../../utils.js';
|
|
21
|
-
import type maplibregl from 'maplibre-gl';
|
|
21
|
+
import type * as maplibregl from 'maplibre-gl';
|
|
22
22
|
import { useControlPosition } from '../../composables/useControlPosition.svelte.js';
|
|
23
23
|
|
|
24
24
|
interface MapContext {
|
|
@@ -336,7 +336,11 @@
|
|
|
336
336
|
if (map.getLayer(layerId) && layerThemes.get(layerId) !== theme) {
|
|
337
337
|
for (const [prop, value] of Object.entries(paint)) {
|
|
338
338
|
try {
|
|
339
|
-
map.setPaintProperty(
|
|
339
|
+
map.setPaintProperty(
|
|
340
|
+
layerId,
|
|
341
|
+
prop as Parameters<maplibregl.Map['setPaintProperty']>[1],
|
|
342
|
+
value as Parameters<maplibregl.Map['setPaintProperty']>[2]
|
|
343
|
+
);
|
|
340
344
|
} catch {
|
|
341
345
|
// Ignore
|
|
342
346
|
}
|
|
@@ -383,7 +387,13 @@
|
|
|
383
387
|
}, 0); // End of setTimeout callback
|
|
384
388
|
});
|
|
385
389
|
|
|
386
|
-
|
|
390
|
+
/**
|
|
391
|
+
* MapLibre 6 types `setPaintProperty`'s name parameter as a union of known
|
|
392
|
+
* paint properties, so this returns the literals rather than `string`.
|
|
393
|
+
*/
|
|
394
|
+
type OpacityProperty = 'fill-opacity' | 'line-opacity' | 'circle-opacity' | 'icon-opacity';
|
|
395
|
+
|
|
396
|
+
function getOpacityProperty(renderType: string): OpacityProperty | null {
|
|
387
397
|
switch (renderType) {
|
|
388
398
|
case 'fill':
|
|
389
399
|
return 'fill-opacity';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import { onMount, onDestroy, setContext } from 'svelte';
|
|
3
3
|
import type { Snippet } from 'svelte';
|
|
4
|
-
import maplibregl from 'maplibre-gl';
|
|
4
|
+
import * as maplibregl from 'maplibre-gl';
|
|
5
5
|
import maplibreStyles from 'maplibre-gl/dist/maplibre-gl.css?inline';
|
|
6
6
|
import controlStyles from '@classic-homes/maps-core/styles/controls.css?inline';
|
|
7
7
|
import markerStyles from '@classic-homes/maps-core/styles/marker.css?inline';
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
import {
|
|
17
17
|
generateMapDescription,
|
|
18
18
|
createPositioningCoordinator,
|
|
19
|
+
warnIfWorkerUrlMissing,
|
|
19
20
|
type PositioningCoordinator,
|
|
20
21
|
} from '@classic-homes/maps-core';
|
|
21
22
|
|
|
@@ -177,6 +178,10 @@
|
|
|
177
178
|
document.head.appendChild(sheet);
|
|
178
179
|
}
|
|
179
180
|
try {
|
|
181
|
+
// MapLibre 6 cannot load its worker under a bundler unless the app set
|
|
182
|
+
// its URL; its own error names the symptom, this warning names the fix.
|
|
183
|
+
warnIfWorkerUrlMissing(maplibregl);
|
|
184
|
+
|
|
180
185
|
const newMap = new maplibregl.Map({
|
|
181
186
|
container: containerElement,
|
|
182
187
|
style: mapStyle as maplibregl.StyleSpecification | string,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import { getContext, onDestroy } from 'svelte';
|
|
3
3
|
import type { Snippet } from 'svelte';
|
|
4
|
-
import maplibregl from 'maplibre-gl';
|
|
4
|
+
import * as maplibregl from 'maplibre-gl';
|
|
5
5
|
import type { MarkerProps, LngLat } from '@classic-homes/maps-core';
|
|
6
6
|
import {
|
|
7
7
|
applyMarkerProtection,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import { getContext, onDestroy, tick } from 'svelte';
|
|
3
3
|
import type { Snippet } from 'svelte';
|
|
4
|
-
import maplibregl from 'maplibre-gl';
|
|
4
|
+
import * as maplibregl from 'maplibre-gl';
|
|
5
5
|
import type { PopupProps } from '@classic-homes/maps-core';
|
|
6
6
|
import { normalizePadding, panToFitPopup } from '@classic-homes/maps-core/utils';
|
|
7
7
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type maplibregl from 'maplibre-gl';
|
|
1
|
+
import type * as maplibregl from 'maplibre-gl';
|
|
2
2
|
import type { BaseLayerProps, FeatureClickEventParams, FeatureHoverEventParams } from '@classic-homes/maps-core';
|
|
3
3
|
/**
|
|
4
4
|
* Extended click event params that include the map instance
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* It provides access to the underlying MapLibre GL map instance for
|
|
6
6
|
* advanced operations like cluster expansion.
|
|
7
7
|
*/
|
|
8
|
-
import type maplibregl from 'maplibre-gl';
|
|
8
|
+
import type * as maplibregl from 'maplibre-gl';
|
|
9
9
|
import type { PositioningCoordinator } from '@classic-homes/maps-core';
|
|
10
10
|
/**
|
|
11
11
|
* Map context interface provided by the Map component
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@classic-homes/maps-svelte",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.1",
|
|
4
4
|
"description": "Svelte MapLibre components for Classic Theme",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"maps",
|
|
@@ -47,8 +47,8 @@
|
|
|
47
47
|
"@deck.gl/core": "^9.0.0",
|
|
48
48
|
"@deck.gl/layers": "^9.0.0",
|
|
49
49
|
"@deck.gl/mapbox": "^9.0.0",
|
|
50
|
-
"maplibre-gl": "^
|
|
51
|
-
"svelte": "^5.
|
|
50
|
+
"maplibre-gl": "^5.0.0 || ^6.11.0",
|
|
51
|
+
"svelte": "^5.31.0"
|
|
52
52
|
},
|
|
53
53
|
"peerDependenciesMeta": {
|
|
54
54
|
"@deck.gl/core": {
|
|
@@ -68,7 +68,7 @@
|
|
|
68
68
|
"@sveltejs/package": "^2.3.0",
|
|
69
69
|
"@sveltejs/vite-plugin-svelte": "^7.0.0",
|
|
70
70
|
"jsdom": "^28.1.0",
|
|
71
|
-
"maplibre-gl": "^
|
|
71
|
+
"maplibre-gl": "^6.14.0",
|
|
72
72
|
"svelte": "^5.0.0",
|
|
73
73
|
"svelte-check": "^4.0.0",
|
|
74
74
|
"typescript": "^5.3.0",
|