【问题标题】:Google map autocomplete for IOS in ionic 2离子2中IOS的谷歌地图自动完成
【发布时间】:2019-05-29 04:37:03
【问题描述】:

我在我的 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();   });

【问题讨论】:

  • 位置在哪里设置? ion-item 未填充 你的意思是离子输入?
  • 是的,对不起。离子输入
  • @Dheena 请看this SO post
  • @sebaferreras 我的问题是,当我从谷歌自动完成中选择地址时,地址没有填充到离子输入中。

标签: ios angular ionic2


【解决方案1】:

更新

您可能使用 CDVUIWebViewEngine。尝试更新到 WKWebView 以解决您的问题;) 您可以找到here 如何升级您的网络视图引擎。 如果您使用 angularhttp,则需要在 iOS 上使用 ionic-native@http(解决 angular-http 和 WKWebView 的 cors 问题的最佳方法)。 祝大家好运:D

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-11-17
    • 2018-01-26
    • 1970-01-01
    • 1970-01-01
    • 2017-07-08
    • 2017-04-14
    相关资源
    最近更新 更多