Fix info window cannot be opened

This commit is contained in:
Fawad Mirzad
2021-02-18 06:07:26 +01:00
parent a436a5be0e
commit be51f9dc59
3 changed files with 11 additions and 10 deletions

View File

@@ -1,7 +1,7 @@
{ {
"name": "@fawmi/vue-google-maps", "name": "@fawmi/vue-google-maps",
"description": "Google Map components for Vue.js 3", "description": "Google Map components for Vue.js 3",
"version": "0.7.10", "version": "0.7.11",
"private": false, "private": false,
"main": "src/main.js", "main": "src/main.js",
"keywords": [ "keywords": [

View File

@@ -25,7 +25,7 @@ const props = {
}, },
} }
const events = ['domready', 'closeclick', 'content_changed'] const events = ['domready', 'click', 'closeclick', 'content_changed']
export default buildComponent({ export default buildComponent({
mappedProps: props, mappedProps: props,
@@ -61,17 +61,14 @@ export default buildComponent({
}) })
} }
}, },
emits: ['closeclick'],
methods: { methods: {
_openInfoWindow() { _openInfoWindow() {
this.$infoWindowObject.close()
if (this.opened) { if (this.opened) {
if (this.$markerObject !== null) {
this.$infoWindowObject.open(this.$map, this.$markerObject) this.$infoWindowObject.open(this.$map, this.$markerObject)
} else { } else {
this.$infoWindowObject.open(this.$map) this.$emit('closeclick')
}
} else {
this.$infoWindowObject.close()
} }
}, },
}, },

View File

@@ -1,5 +1,5 @@
<template> <template>
<div v-if="$slots.default"> <div @click="()=> {console.log('sdfsd')}">
<slot></slot> <slot></slot>
</div> </div>
</template> </template>
@@ -89,6 +89,7 @@ export default buildComponent({
default: null, default: null,
}, },
}, },
emits: events,
unmounted() { unmounted() {
if (!this.$markerObject) { if (!this.$markerObject) {
return return
@@ -114,6 +115,9 @@ export default buildComponent({
if (this.$clusterPromise) { if (this.$clusterPromise) {
this.$clusterPromise.then((co) => { this.$clusterPromise.then((co) => {
co.addMarker(inst) co.addMarker(inst)
inst.addListener('click', ()=> {
this.$emit('click')
});
this.$clusterObject = co this.$clusterObject = co
}) })
} }