Phonegap – 在Apple地图应用程序中打开导航指示

我有两个variables – 目的地和源 – 并使用Phonegap,我试图用jQuery打开外部iPhone苹果地图应用程序的方向。

我正在使用的代码如下所示:

var url = 'http://maps.apple.com/?q=daddr='+destination+'&saddr='+source; window.location = url; 

每当我点击相关的button,它会打开一个新的视图应用程序与谷歌方向作为一个Web视图,我不能回到原来的应用程序。

如何打开链接,而不是iOS默认地图应用程序?

更改http://maps.apple.com/?q=只是maps:做的伎俩。


注意:确保你写maps:而不是map:如,后者将运行正确的应用程序,它会在打开后立即崩溃(感谢jprofitt)

今天,我可以使用以下URLscheme中的一个,使用Cordova应用程序中的标记打开本机Apple Maps应用程序:

 maps://maps.apple.com/?q={latitude},{longitude} 

 maps://?q={latitude},{longitude} 

在一个链接中:

 <a href="maps://maps.apple.com?q={latitude},{longitude}"> <!-- OR --> <a href="maps://?q={latitude},{longitude}"> 

来自JavaScript:

 window.location.href = "maps://maps.apple.com/?q="+lat+","+lng; // OR window.location.href = "maps://?q="+lat+","+lng; 

该应用程序在iOS设备上运行,iOS版本是8.1.2,而cordova-ios是3.7.0版本。

在我的情况下,从http://maps.apple.com/?q=更改为仅maps:?q=没有解决问题。

用标记打开本机Apple Maps的工作scheme如下:

 maps://maps.apple.com/?q={latitude},{longitude} 

完整的工作代码:

 window.location.href = "maps://maps.apple.com/?q="+lat+","+lng; 

使用iOS7.1模拟器进行testing可能无法在更高版本中使用。 我没有机会testing。 抱歉。

支持的Apple Maps参数可以在这里find: https : //developer.apple.com/library/ios/featuredarticles/iPhoneURLScheme_Reference/MapLinks/MapLinks.html

信贷去这个SO链接: 在这里