I have a public object called location
, and when the callback is executed, I need to assign values to that object....
public location: any;
ngOnInit() {
let autocomplete = new google.maps.places.Autocomplete((this.search.nativeElement), {types: ['(cities)']});
//add event listener to Google Autocomplete and capture address input
google.maps.event.addListener(autocomplete, 'place_changed', function () {
let place = autocomplete.getPlace();
});
}
Therefore, I require the place from the addListener
function to be assigned to the public variable location... How can this be achieved?