js-api-loader
js-api-loader copied to clipboard
How does one get the marker to bounce with out using google.maps.Animation.BOUNCE in Vue and Typescript?
Environment details
- Specify the API at the beginning of the title (for example, "Places: ...") No API
- OS type and version Mac OS Ventura 13.4.1
How does one get the marker to bounce with out using google.maps.Animation.BOUNCE? google.maps.Animation.BOUNCE is forcing me to run into "npm run build" errors.
Steps to reproduce
- Run 'npm create vue@latest'
- Run 'npm install @googlemaps/js-api-loader' in side the newly created Vue project
- Copy and paste code sample below in to App.vue
Code example
<script setup lang="ts">
import { onMounted, ref } from 'vue'
import { Loader } from "@googlemaps/js-api-loader"
const loader = new Loader({
apiKey: "",
version: "weekly"
});
const isMarkerBouncing = ref(false);
const mapOptions = {
center: { lat: 0, lng: 0 },
zoom: 4,
mapId: "DEMO_MAP_ID"
};
onMounted(() => {
loader
.importLibrary('maps')
.then(async ({ Map }) => {
const map = new Map(document.getElementById("map"), mapOptions);
const { AdvancedMarkerElement } = await loader.importLibrary('marker');
let advancedMarker = new AdvancedMarkerElement({ map, position: mapOptions.center });
advancedMarker.addListener('click', markerClick());
});
})
const markerClick = () => {
console.log('marker was clicked');
}
const button = () => {
console.log('button was clicked');
}
</script>
<template>
<div id="map" style="width: 500px; height: 500px; background-color: green"></div>
<button @click="button()">Button</button>
</template>
Any guidance is appreciated. Thanks!