FYI, I\'m not a JavaScript Ninja but felt like I\'ll become one when I did a lot of things based on Google Maps recently.
I implemented a map. User can search for go
I had the same problem in Angular2. My solution is to move the initialisation of Google Maps to a function that fires when a user focus in the autocomplete input field. Not the most beautiful solution, but it works.
Code:
private autocomplete_init: boolean: false;
autocompleteFocus() {
this.autocomplete_init = true;
if (!this.autocomplete_init) {
this._autocomplete = new google.maps.places.Autocomplete(document.getElementById("search_address"), {
componentRestrictions: {'country': 'dk'}
}
}
HTML: