我在我的 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/