Hi Guys,
I am using google places autocomplete to suggest schools for my users. The autocomplete is simply not working when I specify the type as school, or point_of_interest as another example. When I specify the type as establishment or geocode the autocomplete works fine.
I am using Ionic 4 and my autocomplete code looks like this:
profile.page.ts
getHighSchoolAutocomplete() {
let input = this.highSchoolText;
this.myHSAutocomplete = new google.maps.places.Autocomplete(input.nativeElement, {types: ['school']});
google.maps.event.addListener(this.myHSAutocomplete, 'place_changed', () => {
// retrieve the place object for your use
let place = this.myHSAutocomplete.getPlace();
console.log('initPlaces place getHighSchoolAutocomplete', place.formatted_address);
this.addressHS = this.tmpParentInfo.get('myHighSchool').setValue(place.formatted_address);
});
}
}
profile.page.html
<h5 class="ion-padding-start">High School:<br></h5>
<input type="text" #highSchoolText formControlName="myHighSchool" class="highSchoolClass"
<script src="https://maps.googleapis.com/maps/api/js?v=3.26&key=MY_API_KEY&libraries=places"></script>