Add support for info window content

This commit is contained in:
Fawad Mirzad
2021-01-27 12:04:35 +01:00
parent 23c0ac636c
commit 182b6df20a
2 changed files with 8 additions and 5 deletions

View File

@@ -10,6 +10,10 @@ export default {
location: { location: {
required: true required: true
}, },
infoWindow: {
type: String,
required: false
},
icon: { icon: {
required: false required: false
} }
@@ -22,7 +26,8 @@ export default {
if (mapPromise) { if (mapPromise) {
mapPromise.then((googleMap) => { mapPromise.then((googleMap) => {
const infoWindow = new google.maps.InfoWindow(); const infoWindow = new google.maps.InfoWindow();
console.log(props.location.lat)
console.log(props.location.lng)
const options = { const options = {
position: new google.maps.LatLng( position: new google.maps.LatLng(
props.location.lat, props.location.lat,
@@ -34,13 +39,11 @@ export default {
if (props.icon) { if (props.icon) {
options.icon = props.icon options.icon = props.icon
} }
const marker = new google.maps.Marker({ const marker = new google.maps.Marker({
...options, ...options,
}); });
marker.addListener("click", (event) => { marker.addListener("click", (event) => {
infoWindow.setContent(`hallo`); infoWindow.setContent(props.infoWindow);
infoWindow.open(googleMap, marker); infoWindow.open(googleMap, marker);
}); });
}); });

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.2.0", "version": "0.2.3",
"private": false, "private": false,
"main": "index.js", "main": "index.js",
"scripts": { "scripts": {