ios - ionic 2 中适用于 IOS 的 Google map 自动完成功能

标签 ios angular ionic2

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

这是我的模板:

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

最佳答案

更新

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

关于ios - ionic 2 中适用于 IOS 的 Google map 自动完成功能,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42872257/

相关文章:

iphone - 使用 sortedArrayUsingFunction 对 NSArray 进行排序

node.js - 如何在 Linux VM 中运行 Node 项目?

android - Html/CSS Display flex 和 align-items center 在 Galaxy Note 3 上不起作用

javascript - Ionic 2 - 在 HTML 中使用 JSON 数组

ios - 如何显示日期和日期的时区,与定义的国家/地区相关?

ios - 如何在 iOS 8 中使用 swift 在 UITableViewCell 中向左滑动时调用电话

ios - AVSpeechSynthesizer 检测语音何时结束

angular - 如何在 IntelliJ 中运行 Angular 应用程序

Angular 4 错误 "Expected 2-3 arguments, but got 1"

javascript - 出现错误 "property does not exist"