From 1e1222f8d0085576043c5aeb93a058e7532db763 Mon Sep 17 00:00:00 2001 From: Oliver Kirsch Date: Sun, 19 Feb 2023 14:14:26 +0100 Subject: [PATCH] Add "emits" to circle and rectangle and register listener to actively propagate events As for vue3, a component can (should?) have an "emits" option containing all its emits. For some components this was implemented, but for rectangle and circle it was missing. Further re-used the addListener code from other components to register listeners to the google maps api events and propagate them to the partent component of a circle/rectangle. --- src/components/circle.js | 8 ++++++++ src/components/rectangle.js | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/src/components/circle.js b/src/components/circle.js index 9dacff5..529bb4c 100644 --- a/src/components/circle.js +++ b/src/components/circle.js @@ -43,4 +43,12 @@ export default buildComponent({ name: 'circle', ctr: () => google.maps.Circle, events, + emits: events, + afterCreate(inst) { + events.forEach((event) => { + inst.addListener(event, (payload) => { + this.$emit(event, payload) + }) + }) + } }) diff --git a/src/components/rectangle.js b/src/components/rectangle.js index aab98da..ca31aba 100644 --- a/src/components/rectangle.js +++ b/src/components/rectangle.js @@ -38,4 +38,12 @@ export default buildComponent({ name: 'rectangle', ctr: () => google.maps.Rectangle, events, + emits: events, + afterCreate(inst) { + events.forEach((event) => { + inst.addListener(event, (payload) => { + this.$emit(event, payload) + }) + }) + } })