簡體   English   中英

在裝有ionic 2的iOS設備上打開行程

[英]Open itinerary on iOS device with ionic 2

我嘗試通過行程打開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設備上運行它,但是當我運行此功能時,沒有任何追加。

問:如何像在Android上那樣打開本機iOS地圖應用程序?

我找到了解決方案。

我在.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="*"/>

工作正常。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM