Loading src/components/LMap.vue +2 −7 Original line number Diff line number Diff line Loading @@ -11,9 +11,8 @@ import { propsBinder, debounce, resetWebpackIcon, generatePlaceholderMethods, provideLeafletMethods, updateLeafletMethod, provideLeafletPlaceholders, } from "../utils.js"; export default { Loading Loading @@ -164,15 +163,12 @@ export default { markerZoomAnimation: props.markerZoomAnimation, }; const schematics = generatePlaceholderMethods([ const schematics = provideLeafletPlaceholders([ "addLayer", "removeLayer", "registerLayerControl", ]); console.log("Providing placeholder addLayer"); provideLeafletMethods(schematics); const eventHandlers = { moveEndHandler() { /** Loading Loading @@ -331,7 +327,6 @@ export default { }, }; console.log("Reassigning addLayer"); updateLeafletMethod(schematics.addLayer, methods.addLayer); updateLeafletMethod(schematics.removeLayer, methods.removeLayer); updateLeafletMethod( Loading src/components/LMarker.vue +2 −3 Original line number Diff line number Diff line Loading @@ -4,7 +4,7 @@ import { remapEvents, propsBinder, debounce, generatePlaceholderMethods, provideLeafletPlaceholders, injectLeafletMethod, updateLeafletMethod, } from "../utils.js"; Loading @@ -20,9 +20,8 @@ export default { const leafletRef = ref({}); const ready = ref(false); const schematics = generatePlaceholderMethods(["latLng"]); const schematics = provideLeafletPlaceholders(["latLng"]); console.log("Injecting addLayer to LMarker"); const addLayer = injectLeafletMethod("addLayer"); const { options, methods } = markerSetup( props, Loading src/components/LTileLayer.vue +0 −1 Original line number Diff line number Diff line Loading @@ -7,7 +7,6 @@ export default { props, setup(props, context) { const leafletRef = ref({}); console.log("injecting addLayer to LTileLayer"); const addLayer = injectLeafletMethod("addLayer"); const { options, methods } = tileLayerSetup(props, leafletRef); Loading src/functions/layer.js +12 −5 Original line number Diff line number Diff line import { onUnmounted, provide } from "vue"; import { injectLeafletMethod } from "../utils"; import { onUnmounted } from "vue"; import { provideLeafletPlaceholders, injectLeafletMethod, updateLeafletMethod, } from "../utils"; export const props = { pane: { Loading Loading @@ -28,7 +32,6 @@ export const props = { }; export const setup = (props, leafletRef, context) => { console.log("injecting addLayer to layer"); const addLayer = injectLeafletMethod("addLayer"); const removeLayer = injectLeafletMethod("removeLayer"); const options = { Loading Loading @@ -87,8 +90,12 @@ export const setup = (props, leafletRef, context) => { }, }; provide("bindTooltip", methods.bindTooltip); provide("unbindTooltip", methods.unbindTooltip); const schematics = provideLeafletPlaceholders([ "bindTooltip", "unbindTooltip", ]); updateLeafletMethod(schematics.bindTooltip, methods.bindTooltip); updateLeafletMethod(schematics.unbindTooltip, methods.unbindTooltip); onUnmounted(() => { methods.unbindPopup(); Loading src/utils.js +12 −11 Original line number Diff line number Diff line Loading @@ -71,19 +71,21 @@ export const resetWebpackIcon = (Icon) => { }); }; export const generatePlaceholderMethods = (methods) => { const base = {}; //reactive({}); return methods.reduce((acc, curr) => { acc[curr] = ref(() => console.warn(`Method ${curr} has been invoked without being replaced`) export const provideLeafletPlaceholders = (methodNames) => { return methodNames.reduce((methods, methodName) => { methods[methodName] = ref(() => console.warn( `Method ${methodName} has been invoked without being replaced` ) ); return acc; }, base); provide(methodName, methods[methodName]); return methods; }, {}); }; export const provideLeafletMethods = (obj) => { for (const key in obj) { provide(key, obj[key]); export const provideLeafletMethods = (methods) => { for (const methodName in methods) { provide(methodName, methods[methodName]); } }; Loading @@ -93,7 +95,6 @@ export const updateLeafletMethod = (methodRef, updateMethod) => { export const injectLeafletMethod = (methodName) => { const method = inject(methodName); console.log("injected method", method); return ( (method && method.value) || (() => console.warn(`"${methodName}" not provided as Leaflet method.`)) Loading Loading
src/components/LMap.vue +2 −7 Original line number Diff line number Diff line Loading @@ -11,9 +11,8 @@ import { propsBinder, debounce, resetWebpackIcon, generatePlaceholderMethods, provideLeafletMethods, updateLeafletMethod, provideLeafletPlaceholders, } from "../utils.js"; export default { Loading Loading @@ -164,15 +163,12 @@ export default { markerZoomAnimation: props.markerZoomAnimation, }; const schematics = generatePlaceholderMethods([ const schematics = provideLeafletPlaceholders([ "addLayer", "removeLayer", "registerLayerControl", ]); console.log("Providing placeholder addLayer"); provideLeafletMethods(schematics); const eventHandlers = { moveEndHandler() { /** Loading Loading @@ -331,7 +327,6 @@ export default { }, }; console.log("Reassigning addLayer"); updateLeafletMethod(schematics.addLayer, methods.addLayer); updateLeafletMethod(schematics.removeLayer, methods.removeLayer); updateLeafletMethod( Loading
src/components/LMarker.vue +2 −3 Original line number Diff line number Diff line Loading @@ -4,7 +4,7 @@ import { remapEvents, propsBinder, debounce, generatePlaceholderMethods, provideLeafletPlaceholders, injectLeafletMethod, updateLeafletMethod, } from "../utils.js"; Loading @@ -20,9 +20,8 @@ export default { const leafletRef = ref({}); const ready = ref(false); const schematics = generatePlaceholderMethods(["latLng"]); const schematics = provideLeafletPlaceholders(["latLng"]); console.log("Injecting addLayer to LMarker"); const addLayer = injectLeafletMethod("addLayer"); const { options, methods } = markerSetup( props, Loading
src/components/LTileLayer.vue +0 −1 Original line number Diff line number Diff line Loading @@ -7,7 +7,6 @@ export default { props, setup(props, context) { const leafletRef = ref({}); console.log("injecting addLayer to LTileLayer"); const addLayer = injectLeafletMethod("addLayer"); const { options, methods } = tileLayerSetup(props, leafletRef); Loading
src/functions/layer.js +12 −5 Original line number Diff line number Diff line import { onUnmounted, provide } from "vue"; import { injectLeafletMethod } from "../utils"; import { onUnmounted } from "vue"; import { provideLeafletPlaceholders, injectLeafletMethod, updateLeafletMethod, } from "../utils"; export const props = { pane: { Loading Loading @@ -28,7 +32,6 @@ export const props = { }; export const setup = (props, leafletRef, context) => { console.log("injecting addLayer to layer"); const addLayer = injectLeafletMethod("addLayer"); const removeLayer = injectLeafletMethod("removeLayer"); const options = { Loading Loading @@ -87,8 +90,12 @@ export const setup = (props, leafletRef, context) => { }, }; provide("bindTooltip", methods.bindTooltip); provide("unbindTooltip", methods.unbindTooltip); const schematics = provideLeafletPlaceholders([ "bindTooltip", "unbindTooltip", ]); updateLeafletMethod(schematics.bindTooltip, methods.bindTooltip); updateLeafletMethod(schematics.unbindTooltip, methods.unbindTooltip); onUnmounted(() => { methods.unbindPopup(); Loading
src/utils.js +12 −11 Original line number Diff line number Diff line Loading @@ -71,19 +71,21 @@ export const resetWebpackIcon = (Icon) => { }); }; export const generatePlaceholderMethods = (methods) => { const base = {}; //reactive({}); return methods.reduce((acc, curr) => { acc[curr] = ref(() => console.warn(`Method ${curr} has been invoked without being replaced`) export const provideLeafletPlaceholders = (methodNames) => { return methodNames.reduce((methods, methodName) => { methods[methodName] = ref(() => console.warn( `Method ${methodName} has been invoked without being replaced` ) ); return acc; }, base); provide(methodName, methods[methodName]); return methods; }, {}); }; export const provideLeafletMethods = (obj) => { for (const key in obj) { provide(key, obj[key]); export const provideLeafletMethods = (methods) => { for (const methodName in methods) { provide(methodName, methods[methodName]); } }; Loading @@ -93,7 +95,6 @@ export const updateLeafletMethod = (methodRef, updateMethod) => { export const injectLeafletMethod = (methodName) => { const method = inject(methodName); console.log("injected method", method); return ( (method && method.value) || (() => console.warn(`"${methodName}" not provided as Leaflet method.`)) Loading