Skip to content

Commit 7c30008

Browse files
committed
Add "emits" to polygon, polyline, circle and rectangle and register listeners
As for vue3, a component should have an "emits" option containing all its emits. For some components this was implemented, but for polygon, polyline, circle and rectangle it was missing.
1 parent 7e482b9 commit 7c30008

File tree

4 files changed

+37
-2
lines changed

4 files changed

+37
-2
lines changed

src/components/circle.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,12 @@ export default buildComponent({
4343
name: 'circle',
4444
ctr: () => google.maps.Circle,
4545
events,
46+
emits: events,
47+
afterCreate(inst) {
48+
events.forEach((event) => {
49+
inst.addListener(event, (payload) => {
50+
this.$emit(event, payload)
51+
})
52+
})
53+
}
4654
})

src/components/polygon.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,10 @@ export default buildComponent({
4343
default: false,
4444
},
4545
},
46-
events,
4746
mappedProps: props,
47+
events,
48+
emits: events,
49+
4850
name: 'polygon',
4951
ctr: () => google.maps.Polygon,
5052

@@ -126,5 +128,11 @@ export default buildComponent({
126128
immediate: true,
127129
}
128130
)
131+
132+
events.forEach((event) => {
133+
inst.addListener(event, (payload) => {
134+
this.$emit(event, payload)
135+
})
136+
})
129137
},
130138
})

src/components/polyline.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,18 +32,23 @@ const events = [
3232
]
3333

3434
export default buildComponent({
35-
mappedProps: props,
3635
props: {
3736
deepWatch: {
3837
type: Boolean,
3938
default: false,
4039
},
4140
},
41+
mappedProps: props,
4242
events,
43+
emits: events,
4344

4445
name: 'polyline',
4546
ctr: () => google.maps.Polyline,
4647

48+
beforeCreate(options) {
49+
if (!options.path) delete options.path
50+
},
51+
4752
afterCreate() {
4853
let clearEvents = () => {}
4954

@@ -78,5 +83,11 @@ export default buildComponent({
7883
immediate: true,
7984
}
8085
)
86+
87+
events.forEach((event) => {
88+
inst.addListener(event, (payload) => {
89+
this.$emit(event, payload)
90+
})
91+
})
8192
},
8293
})

src/components/rectangle.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,12 @@ export default buildComponent({
3838
name: 'rectangle',
3939
ctr: () => google.maps.Rectangle,
4040
events,
41+
emits: events,
42+
afterCreate(inst) {
43+
events.forEach((event) => {
44+
inst.addListener(event, (payload) => {
45+
this.$emit(event, payload)
46+
})
47+
})
48+
}
4149
})

0 commit comments

Comments
 (0)