IOS的Google地图自动填充功能

时间:2017-03-20 07:49:19

标签: ios ionic2

我在我的IOS Ionic 2应用程序中使用谷歌自动完成。当我开始在字段中键入地址时,匹配的地址在下拉列表中显示正常,但如果我选择一个,则不会填充离子输入字段。任何人都可以帮我解决这个问题吗?

模板:

<ion-item>
<ion-input id="journey_from" name="journey_from" type="text" placeholder="" [(ngModel)] = "location"></ion-input>
</ion-item>

组件:

 ngAfterViewInit(){
    let options = {
      componentRestrictions:{
        country: 'IN'
      },
      types: ['(regions)']
    }
    let input = document.getElementById('autocomplete').getElementsByTagName('input')[0];
    let autoComplete = new google.maps.places.Autocomplete(this.autocomplete.nativeElement,options );
    google.maps.event.addListener(autoComplete,'place_changed', () => {
     this.placeSelect = autoComplete.getPlace();
 this.location= this.placeSelect.formatted_address;

     this.changeDetect.detectChanges();   });

0 个答案:

没有答案