@radiofrance/svelte-leaflet 1.0.0-next.2 → 1.0.0-next.3
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 +12 -12
- package/dist/Circle.svelte +45 -0
- package/dist/Circle.svelte.d.ts +8 -0
- package/dist/CircleMarker.svelte +49 -0
- package/dist/CircleMarker.svelte.d.ts +8 -0
- package/dist/ImageOverlay.svelte +66 -0
- package/dist/ImageOverlay.svelte.d.ts +10 -0
- package/dist/LayersControl.svelte +23 -0
- package/dist/LayersControl.svelte.d.ts +6 -0
- package/dist/Map.svelte +34 -9
- package/dist/MarkerClusterGroup.svelte.d.ts +19 -19
- package/dist/Rectangle.svelte +48 -0
- package/dist/Rectangle.svelte.d.ts +8 -0
- package/dist/SVGOverlay.svelte +52 -0
- package/dist/SVGOverlay.svelte.d.ts +8 -0
- package/dist/TileLayer.svelte +34 -0
- package/dist/TileLayer.svelte.d.ts +8 -0
- package/dist/TileLayerWMS.svelte +36 -0
- package/dist/TileLayerWMS.svelte.d.ts +8 -0
- package/dist/Tooltip.svelte +73 -0
- package/dist/Tooltip.svelte.d.ts +10 -0
- package/dist/VideoOverlay.svelte +66 -0
- package/dist/VideoOverlay.svelte.d.ts +10 -0
- package/dist/circleMarker.d.ts +4 -0
- package/dist/circleMarker.js +8 -0
- package/dist/contexts.d.ts +8 -0
- package/dist/contexts.js +18 -0
- package/dist/events.d.ts +1 -1
- package/dist/events.js +1 -1
- package/dist/imageOverlay.d.ts +5 -0
- package/dist/imageOverlay.js +25 -0
- package/dist/map.js +2 -2
- package/dist/marker.js +2 -2
- package/dist/markerClusterGroup.d.ts +1 -1
- package/dist/polyline.js +2 -2
- package/dist/popup.js +2 -2
- package/dist/tileLayer.d.ts +5 -0
- package/dist/tileLayer.js +1 -0
- package/dist/tileLayerWMS.d.ts +7 -0
- package/dist/tileLayerWMS.js +1 -0
- package/dist/tooltip.d.ts +10 -0
- package/dist/tooltip.js +34 -0
- package/dist/utils.d.ts +1 -0
- package/dist/utils.js +7 -0
- package/dist/videoOverlay.d.ts +5 -0
- package/dist/videoOverlay.js +25 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -27,28 +27,28 @@ Simple Leaflet maps for your Svelte projects.
|
|
|
27
27
|
### UI Layers
|
|
28
28
|
|
|
29
29
|
- ✅ Marker
|
|
30
|
-
- DivOverlay
|
|
30
|
+
- DivOverlay _(abstract class)_
|
|
31
31
|
- ✅ Popup
|
|
32
|
-
- Tooltip
|
|
32
|
+
- ✅ Tooltip
|
|
33
33
|
|
|
34
34
|
### Raster Layers
|
|
35
35
|
|
|
36
|
-
- TileLayer
|
|
37
|
-
- TileLayer.WMS
|
|
38
|
-
- ImageOverlay
|
|
39
|
-
- VideoOverlay
|
|
36
|
+
- ✅ TileLayer
|
|
37
|
+
- ✅ TileLayer.WMS
|
|
38
|
+
- ✅ ImageOverlay
|
|
39
|
+
- ✅ VideoOverlay
|
|
40
40
|
|
|
41
41
|
### Vector Layers
|
|
42
42
|
|
|
43
43
|
- Path
|
|
44
44
|
- ✅ Polyline
|
|
45
45
|
- ✅ Polygon
|
|
46
|
-
- Rectangle
|
|
47
|
-
- Circle
|
|
48
|
-
- CircleMarker
|
|
49
|
-
- SVGOverlay
|
|
50
|
-
- SVG
|
|
51
|
-
- Canvas
|
|
46
|
+
- ✅ Rectangle
|
|
47
|
+
- ✅ Circle
|
|
48
|
+
- ✅ CircleMarker
|
|
49
|
+
- ✅ SVGOverlay
|
|
50
|
+
- SVG _(this is a Renderer, won't be implemented)_
|
|
51
|
+
- Canvas _(this is a Renderer, won't be implemented)_
|
|
52
52
|
|
|
53
53
|
### Other Layers
|
|
54
54
|
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { getContext, onDestroy, onMount } from 'svelte';
|
|
3
|
+
import type {
|
|
4
|
+
Circle as LeafletCircle,
|
|
5
|
+
LatLngExpression,
|
|
6
|
+
CircleMarkerOptions,
|
|
7
|
+
LayerGroup,
|
|
8
|
+
} from 'leaflet';
|
|
9
|
+
import { polygonEvents, updatePolylineProps, type PolygonEvents } from './polyline.js';
|
|
10
|
+
import { bindEvents, type LeafletMap } from './index.js';
|
|
11
|
+
import { LAYERGROUP, MAP } from './contexts.js';
|
|
12
|
+
import { circleMarkerEvents, type CircleMarkerEvents } from './circleMarker.js';
|
|
13
|
+
|
|
14
|
+
type Props = {
|
|
15
|
+
latlng: LatLngExpression;
|
|
16
|
+
instance?: LeafletCircle;
|
|
17
|
+
options?: CircleMarkerOptions;
|
|
18
|
+
} & CircleMarkerEvents;
|
|
19
|
+
|
|
20
|
+
let { latlng, instance = $bindable(), options = { radius: 50 }, ...restProps }: Props = $props();
|
|
21
|
+
|
|
22
|
+
const getMap = getContext<() => LeafletMap>(MAP);
|
|
23
|
+
const getLayerGroup = getContext<() => LayerGroup>(LAYERGROUP);
|
|
24
|
+
|
|
25
|
+
onMount(() => {
|
|
26
|
+
const map = getMap?.();
|
|
27
|
+
const layerGroup = getLayerGroup?.();
|
|
28
|
+
const context = layerGroup || map;
|
|
29
|
+
instance = window.L.circle(latlng, { ...options });
|
|
30
|
+
instance.addTo(context);
|
|
31
|
+
bindEvents(instance, restProps, circleMarkerEvents);
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
onDestroy(() => {
|
|
35
|
+
instance?.remove();
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
$effect(() => {
|
|
39
|
+
if (instance && latlng) {
|
|
40
|
+
instance.setLatLng(latlng);
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
// TODO : implement reactivity
|
|
45
|
+
</script>
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Circle as LeafletCircle, LatLngExpression, CircleMarkerOptions } from 'leaflet';
|
|
2
|
+
import { type CircleMarkerEvents } from './circleMarker.js';
|
|
3
|
+
declare const Circle: import("svelte").Component<{
|
|
4
|
+
latlng: LatLngExpression;
|
|
5
|
+
instance?: LeafletCircle;
|
|
6
|
+
options?: CircleMarkerOptions;
|
|
7
|
+
} & CircleMarkerEvents, {}, "instance">;
|
|
8
|
+
export default Circle;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { getContext, onDestroy, onMount } from 'svelte';
|
|
3
|
+
import type {
|
|
4
|
+
CircleMarker as LeafletCircleMarker,
|
|
5
|
+
LatLngExpression,
|
|
6
|
+
CircleMarkerOptions,
|
|
7
|
+
LayerGroup,
|
|
8
|
+
} from 'leaflet';
|
|
9
|
+
import { bindEvents, type LeafletMap } from './index.js';
|
|
10
|
+
import { LAYERGROUP, MAP } from './contexts.js';
|
|
11
|
+
import { circleMarkerEvents, type CircleMarkerEvents } from './circleMarker.js';
|
|
12
|
+
|
|
13
|
+
type Props = {
|
|
14
|
+
latlng: LatLngExpression;
|
|
15
|
+
instance?: LeafletCircleMarker;
|
|
16
|
+
options?: CircleMarkerOptions;
|
|
17
|
+
} & CircleMarkerEvents;
|
|
18
|
+
|
|
19
|
+
let { latlng, instance = $bindable(), options = { radius: 50 }, ...restProps }: Props = $props();
|
|
20
|
+
|
|
21
|
+
const getMap = getContext<() => LeafletMap>(MAP);
|
|
22
|
+
const getLayerGroup = getContext<() => LayerGroup>(LAYERGROUP);
|
|
23
|
+
|
|
24
|
+
onMount(() => {
|
|
25
|
+
const map = getMap?.();
|
|
26
|
+
const layerGroup = getLayerGroup?.();
|
|
27
|
+
const context = layerGroup || map;
|
|
28
|
+
instance = window.L.circleMarker(latlng, { ...options });
|
|
29
|
+
instance.addTo(context);
|
|
30
|
+
bindEvents(instance, restProps, circleMarkerEvents);
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
onDestroy(() => {
|
|
34
|
+
instance?.remove();
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
$effect(() => {
|
|
38
|
+
if (instance && latlng) {
|
|
39
|
+
instance.setLatLng(latlng);
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
// TODO : implement reactivity
|
|
44
|
+
// $effect(() => {
|
|
45
|
+
// if (instance && options) {
|
|
46
|
+
// updatePolylineProps(instance, options);
|
|
47
|
+
// }
|
|
48
|
+
// });
|
|
49
|
+
</script>
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { CircleMarker as LeafletCircleMarker, LatLngExpression, CircleMarkerOptions } from 'leaflet';
|
|
2
|
+
import { type CircleMarkerEvents } from './circleMarker.js';
|
|
3
|
+
declare const CircleMarker: import("svelte").Component<{
|
|
4
|
+
latlng: LatLngExpression;
|
|
5
|
+
instance?: LeafletCircleMarker;
|
|
6
|
+
options?: CircleMarkerOptions;
|
|
7
|
+
} & CircleMarkerEvents, {}, "instance">;
|
|
8
|
+
export default CircleMarker;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { getContext, onDestroy, onMount } from 'svelte';
|
|
3
|
+
import type {
|
|
4
|
+
ImageOverlay as LeafletImageOverlay,
|
|
5
|
+
Map as LeafletMap,
|
|
6
|
+
ImageOverlayOptions,
|
|
7
|
+
LayerGroup,
|
|
8
|
+
LatLngBoundsLiteral,
|
|
9
|
+
} from 'leaflet';
|
|
10
|
+
import {
|
|
11
|
+
imageOverlayEvents,
|
|
12
|
+
updateImageOverlayProps,
|
|
13
|
+
type ImageOverlayEvents,
|
|
14
|
+
} from './imageOverlay.js';
|
|
15
|
+
import { bindEvents } from './index.js';
|
|
16
|
+
import { getOverlaysStore, LAYERGROUP, MAP } from './contexts.js';
|
|
17
|
+
import { getRandomString } from './utils.js';
|
|
18
|
+
|
|
19
|
+
type Props = {
|
|
20
|
+
name?: string;
|
|
21
|
+
url: string;
|
|
22
|
+
bounds: LatLngBoundsLiteral;
|
|
23
|
+
options?: ImageOverlayOptions;
|
|
24
|
+
instance?: LeafletImageOverlay;
|
|
25
|
+
} & ImageOverlayEvents;
|
|
26
|
+
|
|
27
|
+
let {
|
|
28
|
+
name = `overlay-${getRandomString(5)}`,
|
|
29
|
+
url,
|
|
30
|
+
bounds,
|
|
31
|
+
options = {},
|
|
32
|
+
instance = $bindable(),
|
|
33
|
+
...restProps
|
|
34
|
+
}: Props = $props();
|
|
35
|
+
|
|
36
|
+
const getMap = getContext<() => LeafletMap>(MAP);
|
|
37
|
+
const getLayerGroup = getContext<() => LayerGroup>(LAYERGROUP);
|
|
38
|
+
const overlaysStore = getOverlaysStore();
|
|
39
|
+
|
|
40
|
+
onMount(() => {
|
|
41
|
+
const map = getMap?.();
|
|
42
|
+
const layerGroup = getLayerGroup?.();
|
|
43
|
+
const context = layerGroup || map;
|
|
44
|
+
instance = window.L.imageOverlay(url, bounds, options);
|
|
45
|
+
$overlaysStore[name] = instance;
|
|
46
|
+
bindEvents(instance, restProps, imageOverlayEvents);
|
|
47
|
+
instance.addTo(context);
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
onDestroy(() => {
|
|
51
|
+
instance?.remove();
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
$effect(() => {
|
|
55
|
+
if (instance && options) {
|
|
56
|
+
updateImageOverlayProps(instance, options);
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
$effect(() => {
|
|
61
|
+
if (instance && bounds) {
|
|
62
|
+
const latlngBounds = window.L.latLngBounds(bounds);
|
|
63
|
+
instance.setBounds(latlngBounds);
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
</script>
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ImageOverlay as LeafletImageOverlay, ImageOverlayOptions, LatLngBoundsLiteral } from 'leaflet';
|
|
2
|
+
import { type ImageOverlayEvents } from './imageOverlay.js';
|
|
3
|
+
declare const ImageOverlay: import("svelte").Component<{
|
|
4
|
+
name?: string;
|
|
5
|
+
url: string;
|
|
6
|
+
bounds: LatLngBoundsLiteral;
|
|
7
|
+
options?: ImageOverlayOptions;
|
|
8
|
+
instance?: LeafletImageOverlay;
|
|
9
|
+
} & ImageOverlayEvents, {}, "instance">;
|
|
10
|
+
export default ImageOverlay;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { getContext, onMount, tick } from 'svelte';
|
|
3
|
+
import { getBaseLayersStore, getOverlaysStore, MAP } from './contexts.js';
|
|
4
|
+
import type { Control, Map as LeafletMap } from 'leaflet';
|
|
5
|
+
|
|
6
|
+
type Props = {
|
|
7
|
+
instance?: Control;
|
|
8
|
+
options?: Control.LayersOptions;
|
|
9
|
+
};
|
|
10
|
+
let { instance = $bindable(), options }: Props = $props();
|
|
11
|
+
|
|
12
|
+
const getMap = getContext<() => LeafletMap>(MAP);
|
|
13
|
+
const baseLayersStore = getBaseLayersStore();
|
|
14
|
+
const overlaysStore = getOverlaysStore();
|
|
15
|
+
|
|
16
|
+
onMount(async () => {
|
|
17
|
+
const map = getMap();
|
|
18
|
+
// wait for layers to be initialized
|
|
19
|
+
await tick();
|
|
20
|
+
instance = window.L.control.layers($baseLayersStore, $overlaysStore, options);
|
|
21
|
+
instance.addTo(map);
|
|
22
|
+
});
|
|
23
|
+
</script>
|
package/dist/Map.svelte
CHANGED
|
@@ -8,9 +8,15 @@
|
|
|
8
8
|
|
|
9
9
|
import type { MapOptions, Marker, Map as LeafletMap, LatLngTuple } from 'leaflet';
|
|
10
10
|
import { bindEvents } from './index.js';
|
|
11
|
-
import { setContext, type Snippet } from 'svelte';
|
|
11
|
+
import { setContext, tick, type Snippet } from 'svelte';
|
|
12
12
|
import { mapEvents, updateMapProps, type MapEvents } from './map.js';
|
|
13
|
-
import {
|
|
13
|
+
import {
|
|
14
|
+
FOCUSABLE,
|
|
15
|
+
getBaseLayersStore,
|
|
16
|
+
initBaseLayersStore,
|
|
17
|
+
initOverlaysStore,
|
|
18
|
+
MAP,
|
|
19
|
+
} from './contexts.js';
|
|
14
20
|
|
|
15
21
|
type Props = {
|
|
16
22
|
instance?: LeafletMap;
|
|
@@ -27,7 +33,7 @@
|
|
|
27
33
|
options = $bindable({}),
|
|
28
34
|
markers = $bindable([]),
|
|
29
35
|
tilesUrl = 'https://tile.openstreetmap.org/{z}/{x}/{y}.png',
|
|
30
|
-
attribution = `©
|
|
36
|
+
attribution = `© <a href="https://www.openstreetmap.org/copyright" target="_blank">OpenStreetMap</a> contributors`,
|
|
31
37
|
focusable = true,
|
|
32
38
|
children,
|
|
33
39
|
...restProps
|
|
@@ -35,6 +41,10 @@
|
|
|
35
41
|
|
|
36
42
|
setContext(MAP, () => instance);
|
|
37
43
|
setContext(FOCUSABLE, focusable ? null : -1);
|
|
44
|
+
initBaseLayersStore();
|
|
45
|
+
initOverlaysStore();
|
|
46
|
+
const baseLayersStore = getBaseLayersStore();
|
|
47
|
+
|
|
38
48
|
let container: HTMLElement | null = $state(null);
|
|
39
49
|
|
|
40
50
|
const defaultOptions = {
|
|
@@ -51,7 +61,7 @@
|
|
|
51
61
|
}
|
|
52
62
|
});
|
|
53
63
|
|
|
54
|
-
function onLoad() {
|
|
64
|
+
async function onLoad() {
|
|
55
65
|
if (!container) return;
|
|
56
66
|
// @ts-ignore
|
|
57
67
|
delete window.L.Icon.Default.prototype._getIconUrl;
|
|
@@ -69,11 +79,6 @@
|
|
|
69
79
|
}
|
|
70
80
|
bindEvents(instance, restProps, mapEvents);
|
|
71
81
|
|
|
72
|
-
// create component for the tile layer ?
|
|
73
|
-
window.L.tileLayer(tilesUrl, {
|
|
74
|
-
attribution,
|
|
75
|
-
}).addTo(instance);
|
|
76
|
-
|
|
77
82
|
instance.on('layeradd', (event) => {
|
|
78
83
|
const layer = event.layer;
|
|
79
84
|
if (layer instanceof window.L.Marker) {
|
|
@@ -91,6 +96,16 @@
|
|
|
91
96
|
}
|
|
92
97
|
});
|
|
93
98
|
|
|
99
|
+
// waits for the user layers before adding a default layer
|
|
100
|
+
await tick();
|
|
101
|
+
if (!hasTileLayer(instance)) {
|
|
102
|
+
const defaultBaseLayer = window.L.tileLayer(tilesUrl, {
|
|
103
|
+
attribution,
|
|
104
|
+
});
|
|
105
|
+
defaultBaseLayer.addTo(instance);
|
|
106
|
+
$baseLayersStore['Default Layer'] = defaultBaseLayer;
|
|
107
|
+
}
|
|
108
|
+
|
|
94
109
|
instance.whenReady(() => {
|
|
95
110
|
if (!instance) return;
|
|
96
111
|
// TODO: find out why manually firing the load event is needed
|
|
@@ -98,6 +113,16 @@
|
|
|
98
113
|
});
|
|
99
114
|
}
|
|
100
115
|
|
|
116
|
+
function hasTileLayer(map: LeafletMap) {
|
|
117
|
+
let hasTileLayer = false;
|
|
118
|
+
map.eachLayer(function (layer) {
|
|
119
|
+
if (layer instanceof window.L.TileLayer) {
|
|
120
|
+
hasTileLayer = true;
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
return hasTileLayer;
|
|
124
|
+
}
|
|
125
|
+
|
|
101
126
|
function leafletLoader(_node: HTMLElement) {
|
|
102
127
|
(async function () {
|
|
103
128
|
await import('leaflet');
|
|
@@ -8,61 +8,61 @@ declare const MarkerClusterGroup: Component<{
|
|
|
8
8
|
options?: MarkerClusterGroupOptions;
|
|
9
9
|
children?: Snippet;
|
|
10
10
|
} & {
|
|
11
|
-
|
|
11
|
+
onclusterclick?: ((e: Omit<import("leaflet").LeafletMouseEvent, "sourceTarget"> & {
|
|
12
12
|
sourceTarget: import("leaflet").Marker<any>;
|
|
13
13
|
}) => void) | undefined;
|
|
14
|
-
|
|
14
|
+
onclusterdblclick?: ((e: Omit<import("leaflet").LeafletMouseEvent, "sourceTarget"> & {
|
|
15
15
|
sourceTarget: import("leaflet").Marker<any>;
|
|
16
16
|
}) => void) | undefined;
|
|
17
|
-
|
|
17
|
+
onclustermousedown?: ((e: Omit<import("leaflet").LeafletMouseEvent, "sourceTarget"> & {
|
|
18
18
|
sourceTarget: import("leaflet").Marker<any>;
|
|
19
19
|
}) => void) | undefined;
|
|
20
|
-
|
|
20
|
+
onclustermouseup?: ((e: Omit<import("leaflet").LeafletMouseEvent, "sourceTarget"> & {
|
|
21
21
|
sourceTarget: import("leaflet").Marker<any>;
|
|
22
22
|
}) => void) | undefined;
|
|
23
|
-
|
|
23
|
+
onclustermouseover?: ((e: Omit<import("leaflet").LeafletMouseEvent, "sourceTarget"> & {
|
|
24
24
|
sourceTarget: import("leaflet").Marker<any>;
|
|
25
25
|
}) => void) | undefined;
|
|
26
|
-
|
|
26
|
+
onclustermouseout?: ((e: Omit<import("leaflet").LeafletMouseEvent, "sourceTarget"> & {
|
|
27
27
|
sourceTarget: import("leaflet").Marker<any>;
|
|
28
28
|
}) => void) | undefined;
|
|
29
|
-
|
|
29
|
+
onclustercontextmenu?: ((e: Omit<import("leaflet").LeafletMouseEvent, "sourceTarget"> & {
|
|
30
30
|
sourceTarget: import("leaflet").Marker<any>;
|
|
31
31
|
}) => void) | undefined;
|
|
32
|
-
|
|
32
|
+
onclusterdragstart?: ((e: Omit<import("leaflet").LeafletEvent, "sourceTarget"> & {
|
|
33
33
|
sourceTarget: import("leaflet").Marker<any>;
|
|
34
34
|
}) => void) | undefined;
|
|
35
|
-
|
|
35
|
+
onclustermovestart?: ((e: Omit<import("leaflet").LeafletEvent, "sourceTarget"> & {
|
|
36
36
|
sourceTarget: import("leaflet").Marker<any>;
|
|
37
37
|
}) => void) | undefined;
|
|
38
|
-
|
|
38
|
+
onclusterdrag?: ((e: Omit<import("leaflet").LeafletEvent, "sourceTarget"> & {
|
|
39
39
|
sourceTarget: import("leaflet").Marker<any>;
|
|
40
40
|
}) => void) | undefined;
|
|
41
|
-
|
|
41
|
+
onclusterdragend?: ((e: Omit<import("leaflet").DragEndEvent, "sourceTarget"> & {
|
|
42
42
|
sourceTarget: import("leaflet").Marker<any>;
|
|
43
43
|
}) => void) | undefined;
|
|
44
|
-
|
|
44
|
+
onclustermoveend?: ((e: Omit<import("leaflet").LeafletEvent, "sourceTarget"> & {
|
|
45
45
|
sourceTarget: import("leaflet").Marker<any>;
|
|
46
46
|
}) => void) | undefined;
|
|
47
|
-
|
|
47
|
+
onclusteradd?: ((e: Omit<import("leaflet").LeafletEvent, "sourceTarget"> & {
|
|
48
48
|
sourceTarget: import("leaflet").Marker<any>;
|
|
49
49
|
}) => void) | undefined;
|
|
50
|
-
|
|
50
|
+
onclusterremove?: ((e: Omit<import("leaflet").LeafletEvent, "sourceTarget"> & {
|
|
51
51
|
sourceTarget: import("leaflet").Marker<any>;
|
|
52
52
|
}) => void) | undefined;
|
|
53
|
-
|
|
53
|
+
onclusterpopupopen?: ((e: Omit<import("leaflet").PopupEvent, "sourceTarget"> & {
|
|
54
54
|
sourceTarget: import("leaflet").Marker<any>;
|
|
55
55
|
}) => void) | undefined;
|
|
56
|
-
|
|
56
|
+
onclusterpopupclose?: ((e: Omit<import("leaflet").PopupEvent, "sourceTarget"> & {
|
|
57
57
|
sourceTarget: import("leaflet").Marker<any>;
|
|
58
58
|
}) => void) | undefined;
|
|
59
|
-
|
|
59
|
+
onclustertooltipopen?: ((e: Omit<import("leaflet").TooltipEvent, "sourceTarget"> & {
|
|
60
60
|
sourceTarget: import("leaflet").Marker<any>;
|
|
61
61
|
}) => void) | undefined;
|
|
62
|
-
|
|
62
|
+
onclustertooltipclose?: ((e: Omit<import("leaflet").TooltipEvent, "sourceTarget"> & {
|
|
63
63
|
sourceTarget: import("leaflet").Marker<any>;
|
|
64
64
|
}) => void) | undefined;
|
|
65
|
-
|
|
65
|
+
onclustermove?: ((e: Omit<import("leaflet").LeafletEvent, "sourceTarget"> & {
|
|
66
66
|
sourceTarget: import("leaflet").Marker<any>;
|
|
67
67
|
}) => void) | undefined;
|
|
68
68
|
} & import("./utils.js").CreateSvelteEventsMap<readonly ["animationend", "spiderfied", "unspiderfied"]>, {}, "instance">;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { getContext, onDestroy, onMount } from 'svelte';
|
|
3
|
+
import type {
|
|
4
|
+
Rectangle as LeafletRectangle,
|
|
5
|
+
LatLngBoundsExpression,
|
|
6
|
+
PolylineOptions,
|
|
7
|
+
LayerGroup,
|
|
8
|
+
} from 'leaflet';
|
|
9
|
+
import { polygonEvents, updatePolylineProps, type PolygonEvents } from './polyline.js';
|
|
10
|
+
import { bindEvents, type LeafletMap } from './index.js';
|
|
11
|
+
import { LAYERGROUP, MAP } from './contexts.js';
|
|
12
|
+
|
|
13
|
+
type Props = {
|
|
14
|
+
bounds: LatLngBoundsExpression;
|
|
15
|
+
instance?: LeafletRectangle;
|
|
16
|
+
options?: PolylineOptions;
|
|
17
|
+
} & PolygonEvents;
|
|
18
|
+
|
|
19
|
+
let { bounds, instance = $bindable(), options = {}, ...restProps }: Props = $props();
|
|
20
|
+
|
|
21
|
+
const getMap = getContext<() => LeafletMap>(MAP);
|
|
22
|
+
const getLayerGroup = getContext<() => LayerGroup>(LAYERGROUP);
|
|
23
|
+
|
|
24
|
+
onMount(() => {
|
|
25
|
+
const map = getMap?.();
|
|
26
|
+
const layerGroup = getLayerGroup?.();
|
|
27
|
+
const context = layerGroup || map;
|
|
28
|
+
instance = window.L.rectangle(bounds, options);
|
|
29
|
+
instance.addTo(context);
|
|
30
|
+
bindEvents(instance, restProps, polygonEvents);
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
onDestroy(() => {
|
|
34
|
+
instance?.remove();
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
$effect(() => {
|
|
38
|
+
if (instance && bounds) {
|
|
39
|
+
instance.setBounds(bounds);
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
$effect(() => {
|
|
44
|
+
if (instance && options) {
|
|
45
|
+
updatePolylineProps(instance, options);
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
</script>
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Rectangle as LeafletRectangle, LatLngBoundsExpression, PolylineOptions } from 'leaflet';
|
|
2
|
+
import { type PolygonEvents } from './polyline.js';
|
|
3
|
+
declare const Rectangle: import("svelte").Component<{
|
|
4
|
+
bounds: LatLngBoundsExpression;
|
|
5
|
+
instance?: LeafletRectangle;
|
|
6
|
+
options?: PolylineOptions;
|
|
7
|
+
} & PolygonEvents, {}, "instance">;
|
|
8
|
+
export default Rectangle;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { getContext, onDestroy, onMount } from 'svelte';
|
|
3
|
+
import type { SVGOverlay as LeafletSVGOverlay, LayerGroup, LatLngBoundsLiteral } from 'leaflet';
|
|
4
|
+
import { type LeafletMap } from './index.js';
|
|
5
|
+
import { LAYERGROUP, MAP } from './contexts.js';
|
|
6
|
+
|
|
7
|
+
type Props = {
|
|
8
|
+
bounds: LatLngBoundsLiteral;
|
|
9
|
+
instance?: LeafletSVGOverlay;
|
|
10
|
+
options?: object;
|
|
11
|
+
children?: any;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
let { bounds, instance = $bindable(), options = {}, children, ...restProps }: Props = $props();
|
|
15
|
+
let svgContainer: HTMLDivElement | null = $state(null);
|
|
16
|
+
|
|
17
|
+
const getMap = getContext<() => LeafletMap>(MAP);
|
|
18
|
+
const getLayerGroup = getContext<() => LayerGroup>(LAYERGROUP);
|
|
19
|
+
|
|
20
|
+
onMount(() => {
|
|
21
|
+
const map = getMap?.();
|
|
22
|
+
const layerGroup = getLayerGroup?.();
|
|
23
|
+
const context = layerGroup || map;
|
|
24
|
+
const svg = svgContainer?.querySelector('svg');
|
|
25
|
+
if (!svg) {
|
|
26
|
+
throw new Error('SVGOverlay requires an SVG element as a child');
|
|
27
|
+
}
|
|
28
|
+
instance = window.L.svgOverlay(svg, bounds, options);
|
|
29
|
+
instance.addTo(context);
|
|
30
|
+
// bindEvents(instance, restProps);
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
onDestroy(() => {
|
|
34
|
+
instance?.remove();
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
// $effect(() => {
|
|
38
|
+
// if (instance && bounds) {
|
|
39
|
+
// instance.setBounds(window.L.latLngBounds(bounds));
|
|
40
|
+
// }
|
|
41
|
+
// });
|
|
42
|
+
</script>
|
|
43
|
+
|
|
44
|
+
<div bind:this={svgContainer} class="svg-container">
|
|
45
|
+
{@render children()}
|
|
46
|
+
</div>
|
|
47
|
+
|
|
48
|
+
<style>
|
|
49
|
+
.svg-container {
|
|
50
|
+
display: none;
|
|
51
|
+
}
|
|
52
|
+
</style>
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { SVGOverlay as LeafletSVGOverlay, LatLngBoundsLiteral } from 'leaflet';
|
|
2
|
+
declare const SvgOverlay: import("svelte").Component<{
|
|
3
|
+
bounds: LatLngBoundsLiteral;
|
|
4
|
+
instance?: LeafletSVGOverlay;
|
|
5
|
+
options?: object;
|
|
6
|
+
children?: any;
|
|
7
|
+
}, {}, "instance">;
|
|
8
|
+
export default SvgOverlay;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { getContext, onDestroy, onMount } from 'svelte';
|
|
3
|
+
import type { TileLayer as LeafletTileLayer, TileLayerOptions, Map as LeafletMap } from 'leaflet';
|
|
4
|
+
import { getBaseLayersStore, MAP } from './contexts.js';
|
|
5
|
+
import { getRandomString } from './utils.js';
|
|
6
|
+
|
|
7
|
+
type Props = {
|
|
8
|
+
url: string;
|
|
9
|
+
name?: string;
|
|
10
|
+
options?: TileLayerOptions;
|
|
11
|
+
instance?: LeafletTileLayer;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
let {
|
|
15
|
+
url,
|
|
16
|
+
name = `layer-${getRandomString(5)}`,
|
|
17
|
+
options = {},
|
|
18
|
+
instance = $bindable(),
|
|
19
|
+
}: Props = $props();
|
|
20
|
+
|
|
21
|
+
const getMap = getContext<() => LeafletMap>(MAP);
|
|
22
|
+
const baseLayersStore = getBaseLayersStore();
|
|
23
|
+
|
|
24
|
+
onMount(() => {
|
|
25
|
+
const map = getMap();
|
|
26
|
+
instance = window.L.tileLayer(url, options);
|
|
27
|
+
$baseLayersStore[name] = instance;
|
|
28
|
+
instance.addTo(map);
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
onDestroy(() => {
|
|
32
|
+
instance?.remove();
|
|
33
|
+
});
|
|
34
|
+
</script>
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { TileLayer as LeafletTileLayer, TileLayerOptions } from 'leaflet';
|
|
2
|
+
declare const TileLayer: import("svelte").Component<{
|
|
3
|
+
url: string;
|
|
4
|
+
name?: string;
|
|
5
|
+
options?: TileLayerOptions;
|
|
6
|
+
instance?: LeafletTileLayer;
|
|
7
|
+
}, {}, "instance">;
|
|
8
|
+
export default TileLayer;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { getContext, onDestroy, onMount } from 'svelte';
|
|
3
|
+
import type {
|
|
4
|
+
WMSOptions,
|
|
5
|
+
WMSParams,
|
|
6
|
+
TileLayer as LeafletTileLayer,
|
|
7
|
+
Map as LeafletMap,
|
|
8
|
+
} from 'leaflet';
|
|
9
|
+
import { MAP } from './contexts.js';
|
|
10
|
+
|
|
11
|
+
type Props = {
|
|
12
|
+
url: string;
|
|
13
|
+
params?: WMSParams;
|
|
14
|
+
options?: WMSOptions;
|
|
15
|
+
instance?: LeafletTileLayer;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
let {
|
|
19
|
+
url,
|
|
20
|
+
params = { layers: 'wms-default-layer' },
|
|
21
|
+
options = {},
|
|
22
|
+
instance = $bindable(),
|
|
23
|
+
}: Props = $props();
|
|
24
|
+
|
|
25
|
+
const getMap = getContext<() => LeafletMap>(MAP);
|
|
26
|
+
|
|
27
|
+
onMount(() => {
|
|
28
|
+
const map = getMap();
|
|
29
|
+
instance = window.L.tileLayer.wms(url, { ...options, ...params });
|
|
30
|
+
instance.addTo(map);
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
onDestroy(() => {
|
|
34
|
+
instance?.remove();
|
|
35
|
+
});
|
|
36
|
+
</script>
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { WMSOptions, WMSParams, TileLayer as LeafletTileLayer } from 'leaflet';
|
|
2
|
+
declare const TileLayerWms: import("svelte").Component<{
|
|
3
|
+
url: string;
|
|
4
|
+
params?: WMSParams;
|
|
5
|
+
options?: WMSOptions;
|
|
6
|
+
instance?: LeafletTileLayer;
|
|
7
|
+
}, {}, "instance">;
|
|
8
|
+
export default TileLayerWms;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type {
|
|
3
|
+
LatLngExpression,
|
|
4
|
+
TooltipOptions,
|
|
5
|
+
LayerGroup,
|
|
6
|
+
Tooltip as LeafletTooltip,
|
|
7
|
+
Map as LeafletMap,
|
|
8
|
+
Marker as LeafletMarker,
|
|
9
|
+
} from 'leaflet';
|
|
10
|
+
import { getContext, onDestroy, onMount, type Snippet } from 'svelte';
|
|
11
|
+
import { bindEvents } from './index.js';
|
|
12
|
+
import { tooltipEvents, updateTooltipProps, type TooltipEvents } from './tooltip.js';
|
|
13
|
+
import { LAYERGROUP, MAP, MARKER } from './contexts.js';
|
|
14
|
+
|
|
15
|
+
type Props = {
|
|
16
|
+
latlng?: LatLngExpression;
|
|
17
|
+
options?: TooltipOptions;
|
|
18
|
+
instance?: LeafletTooltip;
|
|
19
|
+
children?: Snippet;
|
|
20
|
+
} & TooltipEvents;
|
|
21
|
+
|
|
22
|
+
let {
|
|
23
|
+
latlng,
|
|
24
|
+
options = $bindable({}),
|
|
25
|
+
instance = $bindable(),
|
|
26
|
+
children,
|
|
27
|
+
...restProps
|
|
28
|
+
}: Props = $props();
|
|
29
|
+
|
|
30
|
+
let tooltipContent: HTMLElement | undefined = $state();
|
|
31
|
+
|
|
32
|
+
const getMap = getContext<() => LeafletMap>(MAP);
|
|
33
|
+
const getLayerGroup = getContext<() => LayerGroup>(LAYERGROUP);
|
|
34
|
+
const getMarker = getContext<() => LeafletMarker>(MARKER);
|
|
35
|
+
|
|
36
|
+
onMount(() => {
|
|
37
|
+
const map = getMap?.();
|
|
38
|
+
const layerGroup = getLayerGroup?.();
|
|
39
|
+
const marker = getMarker?.();
|
|
40
|
+
const context = layerGroup || map;
|
|
41
|
+
instance = window.L.tooltip(options);
|
|
42
|
+
if (latlng) instance.setLatLng(latlng);
|
|
43
|
+
bindEvents(instance, restProps, tooltipEvents);
|
|
44
|
+
if (marker) marker.bindTooltip(instance);
|
|
45
|
+
else if (map) instance.openOn(map);
|
|
46
|
+
else instance.addTo(context);
|
|
47
|
+
if (tooltipContent) instance.setContent(tooltipContent);
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
onDestroy(() => {
|
|
51
|
+
instance?.remove();
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
$effect(() => {
|
|
55
|
+
if (instance && options) {
|
|
56
|
+
updateTooltipProps(instance, options);
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
</script>
|
|
60
|
+
|
|
61
|
+
<div class="container">
|
|
62
|
+
{#if children}
|
|
63
|
+
<div bind:this={tooltipContent} class="TooltipChildrenContainer">
|
|
64
|
+
{@render children()}
|
|
65
|
+
</div>
|
|
66
|
+
{/if}
|
|
67
|
+
</div>
|
|
68
|
+
|
|
69
|
+
<style>
|
|
70
|
+
.container {
|
|
71
|
+
display: none;
|
|
72
|
+
}
|
|
73
|
+
</style>
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { LatLngExpression, TooltipOptions, Tooltip as LeafletTooltip } from 'leaflet';
|
|
2
|
+
import { type Snippet } from 'svelte';
|
|
3
|
+
import { type TooltipEvents } from './tooltip.js';
|
|
4
|
+
declare const Tooltip: import("svelte").Component<{
|
|
5
|
+
latlng?: LatLngExpression;
|
|
6
|
+
options?: TooltipOptions;
|
|
7
|
+
instance?: LeafletTooltip;
|
|
8
|
+
children?: Snippet;
|
|
9
|
+
} & TooltipEvents, {}, "instance" | "options">;
|
|
10
|
+
export default Tooltip;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { getContext, onDestroy, onMount } from 'svelte';
|
|
3
|
+
import type {
|
|
4
|
+
VideoOverlay as LeafletVideoOverlay,
|
|
5
|
+
Map as LeafletMap,
|
|
6
|
+
VideoOverlayOptions,
|
|
7
|
+
LayerGroup,
|
|
8
|
+
LatLngBoundsLiteral,
|
|
9
|
+
} from 'leaflet';
|
|
10
|
+
import {
|
|
11
|
+
videoOverlayEvents,
|
|
12
|
+
updateVideoOverlayProps,
|
|
13
|
+
type VideoOverlayEvents,
|
|
14
|
+
} from './videoOverlay.js';
|
|
15
|
+
import { bindEvents } from './index.js';
|
|
16
|
+
import { getOverlaysStore, LAYERGROUP, MAP } from './contexts.js';
|
|
17
|
+
import { getRandomString } from './utils.js';
|
|
18
|
+
|
|
19
|
+
type Props = {
|
|
20
|
+
name?: string;
|
|
21
|
+
url: string | string[] | HTMLVideoElement;
|
|
22
|
+
bounds: LatLngBoundsLiteral;
|
|
23
|
+
options?: VideoOverlayOptions;
|
|
24
|
+
instance?: LeafletVideoOverlay;
|
|
25
|
+
} & VideoOverlayEvents;
|
|
26
|
+
|
|
27
|
+
let {
|
|
28
|
+
name = `overlay-${getRandomString(5)}`,
|
|
29
|
+
url,
|
|
30
|
+
bounds,
|
|
31
|
+
options = {},
|
|
32
|
+
instance = $bindable(),
|
|
33
|
+
...restProps
|
|
34
|
+
}: Props = $props();
|
|
35
|
+
|
|
36
|
+
const getMap = getContext<() => LeafletMap>(MAP);
|
|
37
|
+
const getLayerGroup = getContext<() => LayerGroup>(LAYERGROUP);
|
|
38
|
+
const overlaysStore = getOverlaysStore();
|
|
39
|
+
|
|
40
|
+
onMount(() => {
|
|
41
|
+
const map = getMap?.();
|
|
42
|
+
const layerGroup = getLayerGroup?.();
|
|
43
|
+
const context = layerGroup || map;
|
|
44
|
+
instance = window.L.videoOverlay(url, bounds, options);
|
|
45
|
+
$overlaysStore[name] = instance;
|
|
46
|
+
bindEvents(instance, restProps, videoOverlayEvents);
|
|
47
|
+
instance.addTo(context);
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
onDestroy(() => {
|
|
51
|
+
instance?.remove();
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
$effect(() => {
|
|
55
|
+
if (instance && options) {
|
|
56
|
+
updateVideoOverlayProps(instance, options);
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
$effect(() => {
|
|
61
|
+
if (instance && bounds) {
|
|
62
|
+
const latlngBounds = window.L.latLngBounds(bounds);
|
|
63
|
+
instance.setBounds(latlngBounds);
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
</script>
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { VideoOverlay as LeafletVideoOverlay, VideoOverlayOptions, LatLngBoundsLiteral } from 'leaflet';
|
|
2
|
+
import { type VideoOverlayEvents } from './videoOverlay.js';
|
|
3
|
+
declare const VideoOverlay: import("svelte").Component<{
|
|
4
|
+
name?: string;
|
|
5
|
+
url: string | string[] | HTMLVideoElement;
|
|
6
|
+
bounds: LatLngBoundsLiteral;
|
|
7
|
+
options?: VideoOverlayOptions;
|
|
8
|
+
instance?: LeafletVideoOverlay;
|
|
9
|
+
} & VideoOverlayEvents, {}, "instance">;
|
|
10
|
+
export default VideoOverlay;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { CircleMarker as LeafletCircleMarker } from 'leaflet';
|
|
2
|
+
import type { CreateSvelteEventsMap } from './utils.js';
|
|
3
|
+
export declare const circleMarkerEvents: readonly ["move", "click", "dblclick", "mousedown", "mouseup", "mouseover", "mouseout", "contextmenu", "add", "remove", "popupopen", "popupclose", "tooltipopen", "tooltipclose"];
|
|
4
|
+
export type CircleMarkerEvents = CreateSvelteEventsMap<typeof circleMarkerEvents, LeafletCircleMarker>;
|
package/dist/contexts.d.ts
CHANGED
|
@@ -1,4 +1,12 @@
|
|
|
1
|
+
import { type Writable } from 'svelte/store';
|
|
2
|
+
import type { Control } from 'leaflet';
|
|
1
3
|
export declare const MAP: unique symbol;
|
|
2
4
|
export declare const LAYERGROUP: unique symbol;
|
|
3
5
|
export declare const MARKER: unique symbol;
|
|
4
6
|
export declare const FOCUSABLE: unique symbol;
|
|
7
|
+
type Context = Writable<Control.LayersObject>;
|
|
8
|
+
export declare function initBaseLayersStore(): void;
|
|
9
|
+
export declare function getBaseLayersStore(): Context;
|
|
10
|
+
export declare function initOverlaysStore(): void;
|
|
11
|
+
export declare function getOverlaysStore(): Context;
|
|
12
|
+
export {};
|
package/dist/contexts.js
CHANGED
|
@@ -1,4 +1,22 @@
|
|
|
1
|
+
import { writable } from 'svelte/store';
|
|
2
|
+
import { getContext, setContext } from 'svelte';
|
|
1
3
|
export const MAP = Symbol('map');
|
|
2
4
|
export const LAYERGROUP = Symbol('layerGroup');
|
|
3
5
|
export const MARKER = Symbol('marker');
|
|
4
6
|
export const FOCUSABLE = Symbol('focusable');
|
|
7
|
+
const BASELAYERS = Symbol('baseLayers');
|
|
8
|
+
const OVERLAYS = Symbol('overlays');
|
|
9
|
+
export function initBaseLayersStore() {
|
|
10
|
+
const baseLayers = writable({});
|
|
11
|
+
setContext(BASELAYERS, baseLayers);
|
|
12
|
+
}
|
|
13
|
+
export function getBaseLayersStore() {
|
|
14
|
+
return getContext(BASELAYERS);
|
|
15
|
+
}
|
|
16
|
+
export function initOverlaysStore() {
|
|
17
|
+
const baseLayers = writable({});
|
|
18
|
+
setContext(OVERLAYS, baseLayers);
|
|
19
|
+
}
|
|
20
|
+
export function getOverlaysStore() {
|
|
21
|
+
return getContext(OVERLAYS);
|
|
22
|
+
}
|
package/dist/events.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ export declare const locationEvents: readonly ["locationfound", "locationerror"]
|
|
|
5
5
|
export declare const leafletMouseEvents: readonly ["click", "dblclick", "mousedown", "mouseup", "mouseover", "mouseout", "contextmenu", "mousemove", "preclick"];
|
|
6
6
|
export declare const layerEvents: readonly ["add", "remove"];
|
|
7
7
|
export declare const popupSpecificEvents: readonly ["popupopen", "popupclose"];
|
|
8
|
-
export declare const
|
|
8
|
+
export declare const tooltipSpecificEvents: readonly ["tooltipopen", "tooltipclose"];
|
|
9
9
|
export declare const layerGroupEvents: readonly ["layeradd", "layerremove"];
|
|
10
10
|
export declare const layersControlEvents: readonly ["baselayerchange", "overlayadd", "overlayremove"];
|
|
11
11
|
export declare const mapStateChangeEvents: readonly ["load", "move", "moveend", "movestart", "unload", "viewreset", "zoom", "zoomend", "zoomlevelschange", "zoomstart", "resize"];
|
package/dist/events.js
CHANGED
|
@@ -13,7 +13,7 @@ export const locationEvents = ['locationfound', 'locationerror'];
|
|
|
13
13
|
export const leafletMouseEvents = [...interactiveLayerEvents, 'mousemove', 'preclick'];
|
|
14
14
|
export const layerEvents = ['add', 'remove'];
|
|
15
15
|
export const popupSpecificEvents = ['popupopen', 'popupclose'];
|
|
16
|
-
export const
|
|
16
|
+
export const tooltipSpecificEvents = ['tooltipopen', 'tooltipclose'];
|
|
17
17
|
export const layerGroupEvents = ['layeradd', 'layerremove'];
|
|
18
18
|
export const layersControlEvents = ['baselayerchange', 'overlayadd', 'overlayremove'];
|
|
19
19
|
const leafletEvents = [
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { ImageOverlay as LeafletImageOverlay, ImageOverlayOptions } from 'leaflet';
|
|
2
|
+
import type { CreateSvelteEventsMap } from './utils.js';
|
|
3
|
+
export declare function updateImageOverlayProps(instance: LeafletImageOverlay, options: ImageOverlayOptions): void;
|
|
4
|
+
export declare const imageOverlayEvents: readonly ["click", "dblclick", "mousedown", "mouseup", "mouseover", "mouseout", "contextmenu", "add", "remove", "popupopen", "popupclose", "tooltipopen", "tooltipclose"];
|
|
5
|
+
export type ImageOverlayEvents = CreateSvelteEventsMap<typeof imageOverlayEvents, LeafletImageOverlay>;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { interactiveLayerEvents, layerEvents, popupSpecificEvents, tooltipSpecificEvents, } from './events.js';
|
|
2
|
+
export function updateImageOverlayProps(instance, options) {
|
|
3
|
+
if (!options)
|
|
4
|
+
return;
|
|
5
|
+
for (const [key, value] of Object.entries(options)) {
|
|
6
|
+
if (instance.options[key] === value)
|
|
7
|
+
continue;
|
|
8
|
+
instance.options[key] = value;
|
|
9
|
+
switch (key) {
|
|
10
|
+
case 'opacity':
|
|
11
|
+
case 'alt':
|
|
12
|
+
instance.setOpacity(value);
|
|
13
|
+
break;
|
|
14
|
+
case 'interactive':
|
|
15
|
+
case 'attribution':
|
|
16
|
+
throw new Error(`mutation of ${key} option is not supported`);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
export const imageOverlayEvents = [
|
|
21
|
+
...interactiveLayerEvents,
|
|
22
|
+
...layerEvents,
|
|
23
|
+
...popupSpecificEvents,
|
|
24
|
+
...tooltipSpecificEvents,
|
|
25
|
+
];
|
package/dist/map.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { capitalize } from './utils.js';
|
|
2
|
-
import { keyboardEvents, layerGroupEvents, layersControlEvents, leafletMouseEvents, locationEvents, mapStateChangeEvents, popupSpecificEvents,
|
|
2
|
+
import { keyboardEvents, layerGroupEvents, layersControlEvents, leafletMouseEvents, locationEvents, mapStateChangeEvents, popupSpecificEvents, tooltipSpecificEvents, } from './events.js';
|
|
3
3
|
// stores the function bound to the event listener so it can be removed later
|
|
4
4
|
let boundInvalidateMapSize = null;
|
|
5
5
|
function invalidateMapSize(map) {
|
|
@@ -111,7 +111,7 @@ export const mapEvents = [
|
|
|
111
111
|
...locationEvents,
|
|
112
112
|
...mapStateChangeEvents,
|
|
113
113
|
...popupSpecificEvents,
|
|
114
|
-
...
|
|
114
|
+
...tooltipSpecificEvents,
|
|
115
115
|
'autopanstart',
|
|
116
116
|
'zoomanim',
|
|
117
117
|
];
|
package/dist/marker.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { capitalize } from './utils.js';
|
|
2
|
-
import { draggingEvents, interactiveLayerEvents, layerEvents, popupSpecificEvents,
|
|
2
|
+
import { draggingEvents, interactiveLayerEvents, layerEvents, popupSpecificEvents, tooltipSpecificEvents, } from './events.js';
|
|
3
3
|
// const L = globalThis.window.L;
|
|
4
4
|
export function updateMarkerProps(instance, options) {
|
|
5
5
|
if (!options)
|
|
@@ -57,5 +57,5 @@ export const markerEvents = [
|
|
|
57
57
|
...interactiveLayerEvents,
|
|
58
58
|
...layerEvents,
|
|
59
59
|
...popupSpecificEvents,
|
|
60
|
-
...
|
|
60
|
+
...tooltipSpecificEvents,
|
|
61
61
|
];
|
|
@@ -2,7 +2,7 @@ import { type MarkerEvents } from './marker.js';
|
|
|
2
2
|
import type { CreateSvelteEventsMap } from './utils.js';
|
|
3
3
|
type ClusterifyMarkerEvent<E> = E extends `on${infer N}` ? `oncluster${N}` : never;
|
|
4
4
|
declare const clusterSpecificEvents: readonly ["animationend", "spiderfied", "unspiderfied"];
|
|
5
|
-
export declare const markerClusterGroupEvents: readonly [...("
|
|
5
|
+
export declare const markerClusterGroupEvents: readonly [...("clusterclick" | "clusterdblclick" | "clustermousedown" | "clustermouseup" | "clustermouseover" | "clustermouseout" | "clustercontextmenu" | "clusterdragstart" | "clustermovestart" | "clusterdrag" | "clusterdragend" | "clustermoveend" | "clusteradd" | "clusterremove" | "clusterpopupopen" | "clusterpopupclose" | "clustertooltipopen" | "clustertooltipclose" | "clustermove")[], "animationend", "spiderfied", "unspiderfied"];
|
|
6
6
|
export type MarkerClusterGroupEvents = {
|
|
7
7
|
[K in keyof MarkerEvents as ClusterifyMarkerEvent<K>]: MarkerEvents[K];
|
|
8
8
|
} & CreateSvelteEventsMap<typeof clusterSpecificEvents>;
|
package/dist/polyline.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { interactiveLayerEvents, layerEvents, popupSpecificEvents,
|
|
1
|
+
import { interactiveLayerEvents, layerEvents, popupSpecificEvents, tooltipSpecificEvents, } from './events.js';
|
|
2
2
|
export function updatePolylineProps(instance, options) {
|
|
3
3
|
if (!options)
|
|
4
4
|
return;
|
|
@@ -52,5 +52,5 @@ export const polygonEvents = [
|
|
|
52
52
|
...interactiveLayerEvents,
|
|
53
53
|
...layerEvents,
|
|
54
54
|
...popupSpecificEvents,
|
|
55
|
-
...
|
|
55
|
+
...tooltipSpecificEvents,
|
|
56
56
|
];
|
package/dist/popup.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { interactiveLayerEvents, layerEvents, popupSpecificEvents,
|
|
1
|
+
import { interactiveLayerEvents, layerEvents, popupSpecificEvents, tooltipSpecificEvents, } from './events.js';
|
|
2
2
|
export function updatePopupProps(instance, options) {
|
|
3
3
|
if (!options)
|
|
4
4
|
return;
|
|
@@ -46,5 +46,5 @@ export const popupEvents = [
|
|
|
46
46
|
...interactiveLayerEvents,
|
|
47
47
|
...layerEvents,
|
|
48
48
|
...popupSpecificEvents,
|
|
49
|
-
...
|
|
49
|
+
...tooltipSpecificEvents,
|
|
50
50
|
];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Tooltip as LeafletTooltip, TooltipOptions } from 'leaflet';
|
|
2
|
+
import type { CreateSvelteEventsMap } from './utils.js';
|
|
3
|
+
export declare function updateTooltipProps(instance: LeafletTooltip, options: TooltipOptions): void;
|
|
4
|
+
export declare const tooltipEvents: readonly ["click", "dblclick", "mousedown", "mouseup", "mouseover", "mouseout", "contextmenu", "add", "remove", "tooltipopen", "tooltipclose"];
|
|
5
|
+
export type TooltipEvents = CreateSvelteEventsMap<typeof tooltipEvents, LeafletTooltip>;
|
|
6
|
+
declare module 'leaflet' {
|
|
7
|
+
interface Tooltip {
|
|
8
|
+
_source: Layer;
|
|
9
|
+
}
|
|
10
|
+
}
|
package/dist/tooltip.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { interactiveLayerEvents, layerEvents, tooltipSpecificEvents } from './events.js';
|
|
2
|
+
export function updateTooltipProps(instance, options) {
|
|
3
|
+
if (!options)
|
|
4
|
+
return;
|
|
5
|
+
for (const [key, value] of Object.entries(options)) {
|
|
6
|
+
if (instance.options[key] === value)
|
|
7
|
+
continue;
|
|
8
|
+
instance.options[key] = value;
|
|
9
|
+
switch (key) {
|
|
10
|
+
case 'className':
|
|
11
|
+
case 'interactive':
|
|
12
|
+
case 'pane':
|
|
13
|
+
throw new Error(`mutation of ${key} option is not supported`);
|
|
14
|
+
case 'direction':
|
|
15
|
+
case 'permanent':
|
|
16
|
+
case 'sticky':
|
|
17
|
+
case 'opacity':
|
|
18
|
+
if (instance.isOpen()) {
|
|
19
|
+
const source = instance._source;
|
|
20
|
+
source.closeTooltip();
|
|
21
|
+
source.openTooltip();
|
|
22
|
+
}
|
|
23
|
+
break;
|
|
24
|
+
case 'content':
|
|
25
|
+
instance.setContent(value);
|
|
26
|
+
break;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
export const tooltipEvents = [
|
|
31
|
+
...interactiveLayerEvents,
|
|
32
|
+
...layerEvents,
|
|
33
|
+
...tooltipSpecificEvents,
|
|
34
|
+
];
|
package/dist/utils.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { LeafletEventHandlerFnMap } from 'leaflet';
|
|
2
2
|
export declare function capitalize<T extends string>(str: T): Capitalize<T>;
|
|
3
|
+
export declare function getRandomString(length: number): string;
|
|
3
4
|
export declare function getFirstNonCommentChild(element: HTMLElement): HTMLElement | null;
|
|
4
5
|
export type PickOptionByType<Options, Type> = keyof {
|
|
5
6
|
[K in keyof Options as true extends UnionContainsType<Options[K], Type> ? K : never]: Options[K];
|
package/dist/utils.js
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
export function capitalize(str) {
|
|
2
2
|
return (str[0].toUpperCase() + str.slice(1));
|
|
3
3
|
}
|
|
4
|
+
const chars = 'abcdefghijklmnopqrstuvwxyz0123456789';
|
|
5
|
+
function getRandomChar() {
|
|
6
|
+
return chars[Math.floor(Math.random() * chars.length)];
|
|
7
|
+
}
|
|
8
|
+
export function getRandomString(length) {
|
|
9
|
+
return Array.from({ length }, getRandomChar).join('');
|
|
10
|
+
}
|
|
4
11
|
export function getFirstNonCommentChild(element) {
|
|
5
12
|
let child = element.firstChild;
|
|
6
13
|
while (child && child.nodeType !== Node.ELEMENT_NODE) {
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { VideoOverlay as LeafletVideoOverlay, VideoOverlayOptions } from 'leaflet';
|
|
2
|
+
import type { CreateSvelteEventsMap } from './utils.js';
|
|
3
|
+
export declare function updateVideoOverlayProps(instance: LeafletVideoOverlay, options: VideoOverlayOptions): void;
|
|
4
|
+
export declare const videoOverlayEvents: readonly ["click", "dblclick", "mousedown", "mouseup", "mouseover", "mouseout", "contextmenu", "add", "remove", "popupopen", "popupclose", "tooltipopen", "tooltipclose"];
|
|
5
|
+
export type VideoOverlayEvents = CreateSvelteEventsMap<typeof videoOverlayEvents, LeafletVideoOverlay>;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { interactiveLayerEvents, layerEvents, popupSpecificEvents, tooltipSpecificEvents, } from './events.js';
|
|
2
|
+
export function updateVideoOverlayProps(instance, options) {
|
|
3
|
+
if (!options)
|
|
4
|
+
return;
|
|
5
|
+
for (const [key, value] of Object.entries(options)) {
|
|
6
|
+
if (instance.options[key] === value)
|
|
7
|
+
continue;
|
|
8
|
+
instance.options[key] = value;
|
|
9
|
+
switch (key) {
|
|
10
|
+
case 'opacity':
|
|
11
|
+
case 'alt':
|
|
12
|
+
instance.setOpacity(value);
|
|
13
|
+
break;
|
|
14
|
+
case 'interactive':
|
|
15
|
+
case 'attribution':
|
|
16
|
+
throw new Error(`mutation of ${key} option is not supported`);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
export const videoOverlayEvents = [
|
|
21
|
+
...interactiveLayerEvents,
|
|
22
|
+
...layerEvents,
|
|
23
|
+
...popupSpecificEvents,
|
|
24
|
+
...tooltipSpecificEvents,
|
|
25
|
+
];
|