This repository has been archived by the owner on Oct 25, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ellipse.vue
75 lines (63 loc) · 1.69 KB
/
ellipse.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
<script>
import { h, ref, inject, onMounted, markRaw, provide } from "vue";
import {
remapEvents,
propsBinder,
WINDOW_OR_GLOBAL,
GLOBAL_LEAFLET_OPT,
} from "@vue-leaflet/vue-leaflet/src/utils";
import {
setupCircle,
circleProps,
} from "@vue-leaflet/vue-leaflet/src/functions/circle";
import ellipse from "./ellipse";
const render = (ready, slots) => {
if (ready && slots.default) {
return h("div", { style: { display: "none" } }, slots.default());
}
};
export default {
name: "LEllipse",
props: {
...circleProps,
radius: {
type: [Object, Array],
required: true,
},
tilt: {
type: Number,
default: 0,
},
},
setup(props, context) {
const leafletObject = ref({});
const ready = ref(false);
const addLayer = inject("addLayer");
const useGlobalLeaflet = inject(GLOBAL_LEAFLET_OPT);
const { options, methods } = setupCircle(props, leafletObject, context);
onMounted(async () => {
const { SVG, Canvas, DomEvent } = useGlobalLeaflet
? WINDOW_OR_GLOBAL.L
: await import("leaflet/dist/leaflet-src.esm");
SVG.include(ellipse.update.SVG);
Canvas.include(ellipse.update.Canvas);
leafletObject.value = markRaw(
ellipse.generate(props.latLng, props.radius, props.tilt, options)
);
const listeners = remapEvents(context.attrs);
DomEvent.on(leafletObject.value, listeners);
propsBinder(methods, leafletObject.value, props);
addLayer({
...props,
...methods,
leafletObject: leafletObject.value,
});
ready.value = true;
});
return { ready };
},
render() {
return render(this.ready, this.$slots);
},
};
</script>