我尝试用行程打开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设备上运行它,但是当我运行此功能时,没有任何附加功能。
问:如何打开原生iOS地图应用程序,就像我为Android做的那样?
答案 0 :(得分:0)
我找到了解决方案。
我在.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="*"/>
工作正常。