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.
This commit is contained in:
Oliver Kirsch
2023-02-20 17:07:05 +01:00
parent eb70f3ccd4
commit 43a5f2bf8f
2 changed files with 16 additions and 0 deletions

View File

@@ -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)
})
})
}
})

View File

@@ -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)
})
})
}
})