@radiofrance/svelte-leaflet 0.1.0-alpha.3 → 0.1.0-alpha.5
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/Circle.svelte +26 -0
- package/dist/Circle.svelte.d.ts +22 -0
- package/dist/Marker.svelte +6 -7
- package/dist/Marker.svelte.d.ts +2 -1
- package/dist/Polyline.svelte +1 -1
- package/dist/index.d.ts +1 -1
- package/package.json +7 -5
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
<script>import { createEventDispatcher, getContext, onDestroy, onMount } from "svelte";
|
|
2
|
+
export let center;
|
|
3
|
+
export let options = { radius: 100 };
|
|
4
|
+
let circle;
|
|
5
|
+
let map = getContext("map")();
|
|
6
|
+
const dispatch = createEventDispatcher();
|
|
7
|
+
$:
|
|
8
|
+
updateCicle(center, options);
|
|
9
|
+
function updateCicle(center2, options2) {
|
|
10
|
+
if (circle) {
|
|
11
|
+
circle.setLatLng(center2);
|
|
12
|
+
circle.options = options2;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
onMount(async () => {
|
|
16
|
+
const L = window.L;
|
|
17
|
+
circle = new L.Circle(center, options);
|
|
18
|
+
circle.on("click", (e) => dispatch("click", e));
|
|
19
|
+
circle.addTo(map);
|
|
20
|
+
});
|
|
21
|
+
onDestroy(() => {
|
|
22
|
+
circle?.remove();
|
|
23
|
+
});
|
|
24
|
+
</script>
|
|
25
|
+
|
|
26
|
+
<slot />
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { SvelteComponent } from "svelte";
|
|
2
|
+
import type { LatLngExpression } from 'leaflet';
|
|
3
|
+
declare const __propDef: {
|
|
4
|
+
props: {
|
|
5
|
+
center: LatLngExpression;
|
|
6
|
+
options?: import("leaflet").CircleMarkerOptions | undefined;
|
|
7
|
+
};
|
|
8
|
+
events: {
|
|
9
|
+
click: CustomEvent<any>;
|
|
10
|
+
} & {
|
|
11
|
+
[evt: string]: CustomEvent<any>;
|
|
12
|
+
};
|
|
13
|
+
slots: {
|
|
14
|
+
default: {};
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
export type CircleProps = typeof __propDef.props;
|
|
18
|
+
export type CircleEvents = typeof __propDef.events;
|
|
19
|
+
export type CircleSlots = typeof __propDef.slots;
|
|
20
|
+
export default class Circle extends SvelteComponent<CircleProps, CircleEvents, CircleSlots> {
|
|
21
|
+
}
|
|
22
|
+
export {};
|
package/dist/Marker.svelte
CHANGED
|
@@ -6,29 +6,28 @@ const L = globalThis.window.L;
|
|
|
6
6
|
export let size = 25;
|
|
7
7
|
export let latlng;
|
|
8
8
|
export let id = "";
|
|
9
|
+
export let options = {};
|
|
9
10
|
let markerElement;
|
|
10
11
|
let marker;
|
|
11
12
|
const getMap = getContext("map");
|
|
12
13
|
const getLayerGroup = getContext("layerGroup");
|
|
13
14
|
setContext("layer", () => marker);
|
|
14
15
|
$:
|
|
15
|
-
recreateMarker(size, latlng, id);
|
|
16
|
-
async function recreateMarker(size2, latlng2, id2) {
|
|
16
|
+
recreateMarker(size, latlng, id, options);
|
|
17
|
+
async function recreateMarker(size2, latlng2, id2, options2) {
|
|
17
18
|
removeMarker();
|
|
18
19
|
await tick();
|
|
19
|
-
createMarker(size2, latlng2, id2);
|
|
20
|
+
createMarker(size2, latlng2, id2, options2);
|
|
20
21
|
}
|
|
21
|
-
async function createMarker(size2, latlng2, id2) {
|
|
22
|
+
async function createMarker(size2, latlng2, id2, options2) {
|
|
22
23
|
await tick();
|
|
23
24
|
const layerGroup = getLayerGroup?.();
|
|
24
25
|
const map = getMap();
|
|
25
26
|
const mapOrLayerGroup = layerGroup || map;
|
|
26
|
-
|
|
27
|
-
marker = L.marker(latlng2, markerOptions);
|
|
27
|
+
marker = L.marker(latlng2, options2);
|
|
28
28
|
marker.id = id2;
|
|
29
29
|
marker.on("click", (e) => dispatch("click", e)).on("dblclick", (e) => dispatch("dblclick", e)).on("contextmenu", (e) => dispatch("contextmenu", e));
|
|
30
30
|
mapOrLayerGroup.addLayer(marker);
|
|
31
|
-
const icon = marker.getIcon();
|
|
32
31
|
await tick();
|
|
33
32
|
if (markerElement.childElementCount > 0) {
|
|
34
33
|
marker.setIcon(
|
package/dist/Marker.svelte.d.ts
CHANGED
|
@@ -3,12 +3,13 @@ type MarkerContext = {
|
|
|
3
3
|
id?: string;
|
|
4
4
|
};
|
|
5
5
|
export type Marker = LeafletMarker & MarkerContext;
|
|
6
|
-
import type { LatLngExpression, Marker as LeafletMarker } from 'leaflet';
|
|
6
|
+
import type { LatLngExpression, Marker as LeafletMarker, MarkerOptions } from 'leaflet';
|
|
7
7
|
declare const __propDef: {
|
|
8
8
|
props: {
|
|
9
9
|
size?: number | undefined;
|
|
10
10
|
latlng: LatLngExpression;
|
|
11
11
|
id?: string | undefined;
|
|
12
|
+
options?: MarkerOptions | undefined;
|
|
12
13
|
};
|
|
13
14
|
events: {
|
|
14
15
|
click: CustomEvent<any>;
|
package/dist/Polyline.svelte
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -4,4 +4,4 @@ export { default as MarkerClusterGroup } from './MarkerClusterGroup.svelte';
|
|
|
4
4
|
export { default as Polyline } from './Polyline.svelte';
|
|
5
5
|
export { default as Popup } from './Popup.svelte';
|
|
6
6
|
export type { Marker as LeafletMarker } from './Marker.svelte';
|
|
7
|
-
export type {
|
|
7
|
+
export type { CircleOptions, LatLngExpression, LatLngLiteral, LatLngTuple, LeafletEvent, LeafletKeyboardEvent, LeafletMouseEvent, Map as LeafletMap, MarkerOptions, PathOptions } from 'leaflet';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@radiofrance/svelte-leaflet",
|
|
3
|
-
"version": "0.1.0-alpha.
|
|
3
|
+
"version": "0.1.0-alpha.5",
|
|
4
4
|
"description": "A library that wraps leaflet classes in domless/renderless svelte components.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"svelte",
|
|
@@ -54,8 +54,6 @@
|
|
|
54
54
|
"@types/d3-scale": "^4.0.8",
|
|
55
55
|
"@types/d3-scale-chromatic": "^3.0.3",
|
|
56
56
|
"@types/eslint": "8.56.0",
|
|
57
|
-
"@types/leaflet": "^1.9.8",
|
|
58
|
-
"@types/leaflet.markercluster": "^1.5.4",
|
|
59
57
|
"@typescript-eslint/eslint-plugin": "^6.0.0",
|
|
60
58
|
"@typescript-eslint/parser": "^6.0.0",
|
|
61
59
|
"d3-scale": "^4.0.2",
|
|
@@ -63,8 +61,6 @@
|
|
|
63
61
|
"eslint": "^8.56.0",
|
|
64
62
|
"eslint-config-prettier": "^9.1.0",
|
|
65
63
|
"eslint-plugin-svelte": "^2.35.1",
|
|
66
|
-
"leaflet": "^1.9.4",
|
|
67
|
-
"leaflet.markercluster": "^1.5.3",
|
|
68
64
|
"prettier": "^3.1.1",
|
|
69
65
|
"prettier-plugin-svelte": "^3.1.2",
|
|
70
66
|
"publint": "^0.1.9",
|
|
@@ -82,5 +78,11 @@
|
|
|
82
78
|
"publishConfig": {
|
|
83
79
|
"access": "public",
|
|
84
80
|
"registry": "https://registry.npmjs.org/"
|
|
81
|
+
},
|
|
82
|
+
"dependencies": {
|
|
83
|
+
"@types/leaflet": "^1.9.12",
|
|
84
|
+
"@types/leaflet.markercluster": "^1.5.4",
|
|
85
|
+
"leaflet": "^1.9.4",
|
|
86
|
+
"leaflet.markercluster": "^1.5.3"
|
|
85
87
|
}
|
|
86
88
|
}
|