inocan-group / vue3-google-map

A set of composable components for easy use of Google Maps in your Vue 3 projects.
https://vue3-google-map.com
MIT License
295 stars 60 forks source link

How can the marker animation revolve between zero & one #264

Closed a8300 closed 4 months ago

a8300 commented 4 months ago

Hello,

How does one get the marker animation to change from zero to one and back to zero again. This is what I have so far:

<script setup lang="ts">
import { GoogleMap, Marker } from 'vue3-google-map'

const center = { lat: 40.689247, lng: -74.044502 }
let markerOptions = { animation: 0, position: center, label: 'L', title: 'LADY LIBERTY' }

const clickedMarker = () => {
  if (markerOptions.animation === 1) {
    markerOptions.animation = 0
  } else {
    markerOptions.animation = 1
  }
  console.log('clicked marker animation equals: ', markerOptions.animation)
};
</script>

<template>
  <GoogleMap
    api-key=""
    style="width: 100%; height: 500px"
    :center="center"
    :zoom="15"
    @click=clickedMarker()
  >
    <Marker :options="markerOptions" />
  </GoogleMap>
</template>

Thank you

VictorBalbo commented 4 months ago

I think there are two problems here.

const center = { lat: 40.689247, lng: -74.044502 } let markerOptions = ref({ animation: 0, position: center, label: 'L', title: 'LADY LIBERTY' })

const clickedMarker = () => { if (markerOptions.value.animation === 1) { markerOptions.value.animation = 0 } else { markerOptions.value.animation = 1 } console.log('clicked marker animation equals: ', markerOptions.value.animation) }

a8300 commented 4 months ago

Thank you. I'll incorporate your changes and continue working on it.

a8300 commented 4 months ago

Thank you for your help. Your response helped me resolve the error in another library.