Loading src/components/LPolyline.vue 0 → 100644 +45 −0 Original line number Diff line number Diff line <script> import { onMounted, ref, inject } from "vue"; import { remapEvents, propsBinder } from "../utils.js"; import { props, setup as polylineSetup } from "../functions/polyline"; /** * Polyline component, lets you add and personalize polylines on the map */ export default { name: "LPolyline", props, setup(props, context) { const leafletRef = ref({}); const ready = ref(false); const addLayer = inject("addLayer"); const { options, methods } = polylineSetup(props, leafletRef, context); onMounted(async () => { const { polyline, DomEvent, setOptions } = await import( "leaflet/dist/leaflet-src.esm" ); leafletRef.value = polyline(props.latLngs, options); const listeners = remapEvents(context.attrs); DomEvent.on(leafletRef.value, listeners); propsBinder(methods, leafletRef.value, props, setOptions); addLayer({ ...props, ...methods, leafletObject: leafletRef.value, }); ready.value = true; }); return { ready }; }, render() { return null; }, }; </script> src/functions/polyline.js 0 → 100644 +45 −0 Original line number Diff line number Diff line import { props as pathProps, setup as pathSetup } from "../functions/path"; export const props = { ...pathProps, latLngs: { type: Array, default: () => [], }, smoothFactor: { type: Number, custom: true, default: 1.0, }, noClip: { type: Boolean, custom: true, default: false, }, }; export const setup = (props, leafletRef, context) => { const { options: pathOptions, methods: pathMethods } = pathSetup( props, leafletRef, context ); const options = { ...pathOptions, ...props, }; const methods = { ...pathMethods, setSmoothFactor(smoothFactor) { leafletRef.value.setStyle({ smoothFactor }); }, setNoClip(noClip) { leafletRef.value.setStyle({ noClip }); }, addLatLng(latLng) { leafletRef.value.addLatLng(latLng); }, }; return { options, methods }; }; Loading
src/components/LPolyline.vue 0 → 100644 +45 −0 Original line number Diff line number Diff line <script> import { onMounted, ref, inject } from "vue"; import { remapEvents, propsBinder } from "../utils.js"; import { props, setup as polylineSetup } from "../functions/polyline"; /** * Polyline component, lets you add and personalize polylines on the map */ export default { name: "LPolyline", props, setup(props, context) { const leafletRef = ref({}); const ready = ref(false); const addLayer = inject("addLayer"); const { options, methods } = polylineSetup(props, leafletRef, context); onMounted(async () => { const { polyline, DomEvent, setOptions } = await import( "leaflet/dist/leaflet-src.esm" ); leafletRef.value = polyline(props.latLngs, options); const listeners = remapEvents(context.attrs); DomEvent.on(leafletRef.value, listeners); propsBinder(methods, leafletRef.value, props, setOptions); addLayer({ ...props, ...methods, leafletObject: leafletRef.value, }); ready.value = true; }); return { ready }; }, render() { return null; }, }; </script>
src/functions/polyline.js 0 → 100644 +45 −0 Original line number Diff line number Diff line import { props as pathProps, setup as pathSetup } from "../functions/path"; export const props = { ...pathProps, latLngs: { type: Array, default: () => [], }, smoothFactor: { type: Number, custom: true, default: 1.0, }, noClip: { type: Boolean, custom: true, default: false, }, }; export const setup = (props, leafletRef, context) => { const { options: pathOptions, methods: pathMethods } = pathSetup( props, leafletRef, context ); const options = { ...pathOptions, ...props, }; const methods = { ...pathMethods, setSmoothFactor(smoothFactor) { leafletRef.value.setStyle({ smoothFactor }); }, setNoClip(noClip) { leafletRef.value.setStyle({ noClip }); }, addLatLng(latLng) { leafletRef.value.addLatLng(latLng); }, }; return { options, methods }; };