Skip to content

Commit

Permalink
Add "emits" to circle and rectangle and register listener to actively…
Browse files Browse the repository at this point in the history
… 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.
  • Loading branch information
Oliver Kirsch committed Feb 19, 2023
1 parent 0ea377c commit 1e1222f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/components/circle.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
})
}
})
8 changes: 8 additions & 0 deletions src/components/rectangle.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
})
}
})

0 comments on commit 1e1222f

Please sign in to comment.