Trying to set up a Google map in a vue.js project has been challenging. I have included the script like this:
<script src="https://maps.googleapis.com/maps/api/js?key=MY_API_KEY&callback=initMap" async defer></script>
The issue arises with my .vue files looking like this:
<template>
...
</template>
<script>
...
</script>
I am unable to add more than one script tag in my vue file, and although I could display the map by placing code in the index.html, I would prefer not to mix JS in that file. Additionally, I am unable to direct the script callback to a vue method.
Does anyone have any suggestions on how to incorporate the map using a .vue file? I did try using vue2-google-maps but I wish to utilize the original Google map.
A fiddle I created demonstrates some success without a callback in the script tag: https://jsfiddle.net/okubdoqa/, however, I am facing difficulties making it work. Thank you.