I have 2 search boxes with autocomplete.
The first search box is for user to select an address from google autocomplete.
I want to pass the address from the first search box to the second search box by default. The user can update the second search box if they choose to.
I tried passing the address to the second search box but got an error Unhandled rejection TypeError: Cannot read properties of undefined (reading ‘activeElement’)
Is there a way to do this?
//pass the full address from the first search box to the second search box
this.autocomplete(this.fulladdress);
//autocomplete function. This is also where I get the full address from the first search box
private autocomplete(input: any) {
let autocomplete: google.maps.places.Autocomplete;
autocomplete = new google.maps.places.Autocomplete(
input
);
autocomplete.setComponentRestrictions({ country: ["au"] });
autocomplete.addListener("place_changed", () => {
let place = autocomplete.getPlace();
if (place == null || place.address_components == null) {
return;
}
....
this.fulladdress = place.formatted_address;
....
}