I'm implementing an autocomplete input box using the Google place API. I understand that the API URL requires a callback function for initializing the map.
I'm referencing the place API URL in index.html header:
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />>
<script async src="https://maps.googleapis.com/maps/api/js?key=[KEY]&libraries=places"></script>
<title>DocBay</title>
</head>
and initializing the API in the component onMount Hook
onMounted(() => {
autocomplete.value = new google.maps.places.Autocomplete(document.getElementById('autocomplete'), {
componentRestrictions: { country: ['us'] },
fields: ['address_components'],
types: ['address']
})
autocomplete.value.addListener('place_changed', fillInAddress)
})
This results in this error:
Loading the Google Maps JavaScript API without a callback is not supported
since I've to include the Google Maps Places API in the of my HTML and can't define the callback function in there, how do I get rid of this error?