I'm trying to render a vue js component which is simply -
var infowindow_content = "<google-map-infowindow ";
infowindow_content += "content='Hello World'";
infowindow_content += "></google-map-infowindow>";
by passing it into the marker's infowindow
this.current_infowindow = new google.maps.InfoWindow({
    content: infowindow_content,
});
this.current_infowindow.open(context.mapObject, marker);
And the vueJS component being -
<template>
    <div>
        {{content}}
    </div>
</template>
<script>
module.exports = {
    name: 'google-map-infowindow',
    props: [ 
        'content',
    ],
}
</script>
However, this doesn't work and the window is blank.
After revisiting this today I was able to do this by programmatically creating an instance of the vue component and mounting it before simply passing its rendered HTML template as the infowindow's content.
InfoWindow.vue
<template>
    <div>
        {{content}}
    </div>
</template>
<script>
module.exports = {
    name: 'infowindow',
    props: [ 
        'content',
    ],
}
</script>
And in the portion of the code that is required to create before opening the info-window:
...
import InfoWindowComponent from './InfoWindow.vue';
...
var InfoWindow = Vue.extend(InfoWindowComponent);
var instance = new InfoWindow({
    propsData: {
        content: "This displays as info-window content!"
    }
});
instance.$mount();
var new_infowindow = new google.maps.InfoWindow({
    content: instance.$el,
});
new_infowindow.open(<map object>, <marker>);
Note: I haven't experimented with watchers and event-driven calls for this.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With