Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG]: Not able to make it work with google places library in Ionic #79

Open
SumeetHindinkeri opened this issue Oct 5, 2020 · 2 comments
Labels
bug Something isn't working good first issue Good for newcomers

Comments

@SumeetHindinkeri
Copy link

SumeetHindinkeri commented Oct 5, 2020

I'm submitting a

  • [x ] Bug report

Description

I am trying to use it with get places library of google to show the dropdown of places. I tried with simple function option and function, service option but I get following error. I am getting the results in console log but before that this error popup and dropdown doesn't showup.

core.js:7376 ERROR TypeError: Cannot read property 'length' of undefined
    at AutoCompleteComponent.push../node_modules/ionic4-auto-complete/fesm5/ionic4-auto-complete.js.AutoCompleteComponent.removeDuplicates (ionic4-auto-complete.js:530)
    at AutoCompleteComponent.push../node_modules/ionic4-auto-complete/fesm5/ionic4-auto-complete.js.AutoCompleteComponent.setSuggestions (ionic4-auto-complete.js:633)
    at ionic4-auto-complete.js:317
    at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask (zone.js:423)
    at Object.onInvokeTask (core.js:26760)
    at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask (zone.js:422)
    at Zone.push../node_modules/zone.js/dist/zone.js.Zone.runTask (zone.js:195)
    at push../node_modules/zone.js/dist/zone.js.ZoneTask.invokeTask (zone.js:498)
    at ZoneTask.invoke (zone.js:487)
    at timer (zone.js:3070)

I am trying with following code:

    let addresses = [];
    new google.maps.places.AutocompleteService().getPlacePredictions({
      input: addressQuery,
      componentRestrictions: {},
      // bounds: defaultBounds
    }, (predictions) => {
      console.log(predictions);
      addresses = predictions;
      return addresses;
    })

Version Information

ionic4-auto-complete: 2.7.1
@angular/cli: 8.1.3
@jrquick17
Copy link
Owner

@SumeetHindinkeri can you share your full provider code?

@jrquick17 jrquick17 added bug Something isn't working good first issue Good for newcomers labels Apr 12, 2021
@SumeetHindinkeri
Copy link
Author

@jrquick17 The code that I posted above was actually my provider code with getResults function like below:

export class MapService implements AutoCompleteService {

public getResults(addressQuery) {
let addresses = [];
new google.maps.places.AutocompleteService().getPlacePredictions({
input: addressQuery
// bounds: defaultBounds
}, (predictions) => {
console.log(predictions);
addresses = predictions;
return addresses;
})
}
}

And html code:

<ion-auto-complete *ngIf='isEditable' [dataProvider]='mapService' (itemSelected)='onAddressInput($event)'
(ngModelChange)='clearInput()' [options]='{ placeholder : lAddressPlaceholder, debounce : "1000", clearIcon:"null"}'
[autoFocusSuggestion]='false' [(ngModel)]='address'>

Though I moved to different plugin afterwards.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants