Google AutoComplete Is Not Working In Ionic

ionViewWillEnter() {
    let SearchedData = (document.getElementById("Search").getElementsByTagName('input')[0]);
    let options = {
        types: []
    };

    let autocomplete1 = new google.maps.places.Autocomplete(SearchedData, options);
    google.maps.event.addListener(autocomplete1, 'place_changed', () => {
        this.place = autocomplete1.getPlace();
        let geometry = this.place.geometry;
        if ((geometry) != undefined) {
            var lat = geometry.location.lat();
            var lng = geometry.location.lng();
            alert(lat);
}

Hi guys i am using this code for google autocomplete and its working fine in browser.
but in ios its not working. the problem is place_changed event is not getting called

Any Suggestion will be appreciated.

1 Like

can you show me how you are importing google maps js API in your project?

i have added
"<script src="https://maps.googleapis.com/maps/api/js?v=3.exp&libraries=places"
this line in my index.html page

1 Like

What kind of issues are you seeing in the console?

You may have to use ngAfterViewInit because that’s when angular can read dom events.

This seems to be persisting even in ionic 3. Has someone found a workaround or unearthed the reason for this issue?

1 Like