我尝试使用行程打开iOS的本机映射。
使用Android我使用此:
openNativeMap() {
var coords = this.group.latitude + "," + this.group.latitude;
let address_to_request = this.group.address + "+" + this.group.city;
window.open("http://maps.google.com/maps?q=" + coords + "&daddr="+ address_to_request +"&f=d&mode=driving");
return;
}
它在Android上起作用,但显然不适合iOS。
所以我找到了这个解决方案:
openNativeMap() {
var coords = this.group.latitude + "," + this.group.latitude;
let address_to_request = this.group.address + "+" + this.group.city;
window.open('maps://?q=' + 'MyLocation' + '&saddr=' + '200' + ',' + '200' + '&daddr=' + coords, '_system');
return;
}
我尝试在iOS设备上运行它,但是当我运行此功能时,没有任何附加。
Q:如何像为Android打开本机iOS Maps应用程序?
我找到了一个解决方案。
我在.ts文件中写下此代码:
openNativeMap() {
var coords = this.group.latitude + "," + this.group.longitude;
let url: string = "maps://maps.apple.com/?q=" + coords;
let address_to_request = this.group.address + "+" + this.group.city;
window.location.href = url;
return;
}
,我在我的config.xml
中添加了这一行<allow-navigation href="*"/>
它可以正常工作。