Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nuxt example and click to open infowindow #106

Open
GerritKuilder opened this issue Jan 1, 2022 · 4 comments
Open

Nuxt example and click to open infowindow #106

GerritKuilder opened this issue Jan 1, 2022 · 4 comments

Comments

@GerritKuilder
Copy link

Hi

I needed to fix a small typo in the nuxt example that was on the page, after that the map loaded find

    <google-map-infowindow
        :position="infoWindowContext.position

There was a capital I in WIndowcontext

But I still can't get the infowindow to work, I added a console.log in the click function, this shows me the click does not work at all.

Kind Regards,

Gerrit Kuilder

@TouchSek
Copy link
Collaborator

@GerritKuilder thank you. we will check this.

@ribrewguy
Copy link

Same issue without nuxt. Clicking on a marker doesn't do anything. The click event callback is never executed.

@chantouchsek
Copy link
Owner

chantouchsek commented Mar 6, 2022

@chantouchsek
Copy link
Owner

The code should look like this:

<template lang="html">
  <div class="info-windows">
    <google-map id="map" ref="Map">
      <google-map-marker
        :key="index"
        v-for="(info, index) in infoWindowsList"
        :position="info.position"
        @click="toggleInfoWindow(info)"
      />
      <google-map-infowindow
              v-for="(info, index) in infoWindowsList"
              :key="`info-window-${index}`"
              :position="info.position"
              :show.sync="showInfo"
              :options="{maxWidth: 300}"
              @info-window-clicked="infoClicked($event, info)"
      >
        <h4 >{{infoWindowContext.title}}</h4>
        <p>{{infoWindowContext.description}}</p>
      </google-map-infowindow>
    </google-map>
  </div>
</template>

<script>
import cities from '../assets/cities.json'
export default {
  data () {
    return {
      showInfo: true,
      infoWindowContext: {
        title: 'Hello world',
        description: 'Description',
        position: {
          lat: 44.2899,
          lng: 11.8774
        }
      },
      infoWindowsList: cities
    }
  },
  methods: {
    toggleInfoWindow (context) {
      this.infoWindowContext = context
      this.showInfo = true
    },
    infoClicked(context, spot) {
      console.log('infoClicked', context, spot)
    }
  }
}
</script>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants