@radiofrance/svelte-leaflet 0.1.0-alpha.13 → 0.1.0-alpha.15
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/Polygon.svelte +26 -0
- package/dist/Polygon.svelte.d.ts +35 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +7 -0
- package/package.json +1 -1
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
<script>import { createEventDispatcher, getContext, onDestroy, onMount } from "svelte";
|
|
2
|
+
import { bindEvents, polygonEvents } from "./index.js";
|
|
3
|
+
export let latlngs;
|
|
4
|
+
export let options = {};
|
|
5
|
+
export let instance = void 0;
|
|
6
|
+
let map = getContext("map")();
|
|
7
|
+
const dispatch = createEventDispatcher();
|
|
8
|
+
$: update(latlngs, options);
|
|
9
|
+
function update(latlngs2, options2) {
|
|
10
|
+
if (instance) {
|
|
11
|
+
instance.setLatLngs(latlngs2);
|
|
12
|
+
instance.setStyle(options2);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
onMount(async () => {
|
|
16
|
+
const L = window.L;
|
|
17
|
+
instance = new L.Polygon(latlngs, options);
|
|
18
|
+
bindEvents(instance, dispatch, polygonEvents);
|
|
19
|
+
instance.addTo(map);
|
|
20
|
+
});
|
|
21
|
+
onDestroy(() => {
|
|
22
|
+
instance?.remove();
|
|
23
|
+
});
|
|
24
|
+
</script>
|
|
25
|
+
|
|
26
|
+
<slot />
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { SvelteComponent } from "svelte";
|
|
2
|
+
import type { Polygon as LeafletPolygon, PolylineOptions, LatLngExpression } from 'leaflet';
|
|
3
|
+
declare const __propDef: {
|
|
4
|
+
props: {
|
|
5
|
+
latlngs: LatLngExpression[];
|
|
6
|
+
options?: PolylineOptions | undefined;
|
|
7
|
+
instance?: LeafletPolygon | undefined;
|
|
8
|
+
};
|
|
9
|
+
events: {
|
|
10
|
+
click: CustomEvent<import("leaflet").LeafletMouseEvent>;
|
|
11
|
+
dblclick: CustomEvent<import("leaflet").LeafletMouseEvent>;
|
|
12
|
+
mousedown: CustomEvent<import("leaflet").LeafletMouseEvent>;
|
|
13
|
+
mouseup: CustomEvent<import("leaflet").LeafletMouseEvent>;
|
|
14
|
+
mouseover: CustomEvent<import("leaflet").LeafletMouseEvent>;
|
|
15
|
+
mouseout: CustomEvent<import("leaflet").LeafletMouseEvent>;
|
|
16
|
+
contextmenu: CustomEvent<import("leaflet").LeafletMouseEvent>;
|
|
17
|
+
popupopen: CustomEvent<import("leaflet").PopupEvent>;
|
|
18
|
+
popupclose: CustomEvent<import("leaflet").PopupEvent>;
|
|
19
|
+
tooltipopen: CustomEvent<import("leaflet").TooltipEvent>;
|
|
20
|
+
tooltipclose: CustomEvent<import("leaflet").TooltipEvent>;
|
|
21
|
+
add: CustomEvent<import("leaflet").LeafletEvent>;
|
|
22
|
+
remove: CustomEvent<import("leaflet").LeafletEvent>;
|
|
23
|
+
} & {
|
|
24
|
+
[evt: string]: CustomEvent<any>;
|
|
25
|
+
};
|
|
26
|
+
slots: {
|
|
27
|
+
default: {};
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
export type PolygonProps = typeof __propDef.props;
|
|
31
|
+
export type PolygonEvents = typeof __propDef.events;
|
|
32
|
+
export type PolygonSlots = typeof __propDef.slots;
|
|
33
|
+
export default class Polygon extends SvelteComponent<PolygonProps, PolygonEvents, PolygonSlots> {
|
|
34
|
+
}
|
|
35
|
+
export {};
|
package/dist/index.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ export { default as MarkerClusterGroup } from './MarkerClusterGroup.svelte';
|
|
|
6
6
|
export { default as Polyline } from './Polyline.svelte';
|
|
7
7
|
export { default as Popup } from './Popup.svelte';
|
|
8
8
|
export { default as Circle } from './Circle.svelte';
|
|
9
|
+
export { default as Polygon } from './Polygon.svelte';
|
|
9
10
|
export type { Marker as LeafletMarker } from './Marker.svelte';
|
|
10
11
|
export type { Circle as LeafletCircle, CircleOptions, DragEndEvent, ErrorEvent, LatLngExpression, LatLngLiteral, LatLngTuple, LayerEvent, LayersControlEvent, LeafletEvent, LeafletKeyboardEvent, LeafletMouseEvent, LocationEvent, Map as LeafletMap, MapOptions, MarkerOptions, PathOptions, PopupEvent, PopupOptions, ResizeEvent, TooltipEvent } from 'leaflet';
|
|
11
12
|
export declare function bindEvents(instance: Evented, dispatch: EventDispatcher<Record<string, unknown>>, events: readonly string[]): void;
|
|
@@ -20,6 +21,7 @@ export declare const layerGroupEvents: readonly ["layeradd", "layerremove"];
|
|
|
20
21
|
export declare const layersControlEvents: readonly ["baselayerchange", "overlayadd", "overlayremove"];
|
|
21
22
|
declare const leafletEvents: readonly ["load", "move", "moveend", "movestart", "unload", "viewreset", "zoom", "zoomend", "zoomlevelschange", "zoomstart"];
|
|
22
23
|
export declare const mapStateChangeEvents: readonly ["load", "move", "moveend", "movestart", "unload", "viewreset", "zoom", "zoomend", "zoomlevelschange", "zoomstart", "resize"];
|
|
24
|
+
export declare const polygonEvents: readonly ["tooltipopen", "tooltipclose", "add", "remove", "popupopen", "popupclose", "click", "dblclick", "mousedown", "mouseup", "mouseover", "mouseout", "contextmenu"];
|
|
23
25
|
type LeafletEventTypes = {
|
|
24
26
|
resize: ResizeEvent;
|
|
25
27
|
locationerror: ErrorEvent;
|
package/dist/index.js
CHANGED
|
@@ -5,6 +5,7 @@ export { default as MarkerClusterGroup } from './MarkerClusterGroup.svelte';
|
|
|
5
5
|
export { default as Polyline } from './Polyline.svelte';
|
|
6
6
|
export { default as Popup } from './Popup.svelte';
|
|
7
7
|
export { default as Circle } from './Circle.svelte';
|
|
8
|
+
export { default as Polygon } from './Polygon.svelte';
|
|
8
9
|
export function bindEvents(instance, dispatch, events) {
|
|
9
10
|
events.forEach((event) => {
|
|
10
11
|
instance.on(event, (e) => dispatch(event, e));
|
|
@@ -55,3 +56,9 @@ const leafletEvents = [
|
|
|
55
56
|
'zoomstart'
|
|
56
57
|
];
|
|
57
58
|
export const mapStateChangeEvents = [...leafletEvents, 'resize'];
|
|
59
|
+
export const polygonEvents = [
|
|
60
|
+
...tooltipEvents,
|
|
61
|
+
...layerEvents,
|
|
62
|
+
...popupEvents,
|
|
63
|
+
...interactiveLayerEvents
|
|
64
|
+
];
|