iOS – 打开带有经纬度方向的Apple地图

我正在开发一个应用程序需要打开一个Apple Maps会话,并传递经纬度坐标来获取从用户当前位置到该位置的路线。

我知道这可以在谷歌地图,我已经做了,但试图打开在苹果地图的URL时,它只是打开的地方,而不是从用户当前位置到目的地的方向。

这是我一直在使用的URLscheme:

http://maps.apple.com/?ll=(someLatitude),(someLongitute) 

码:

 UIApplication.sharedApplication().openURL(NSURL(string:"http://maps.apple.com/?ll=\(locationLat),\(locationlong)")!) 

任何帮助将不胜感激。 谢谢!

试试这个代码,AppleMap将打开方向标记从设备的当前位置到指定位置的坐标。

  let coordinate = CLLocationCoordinate2DMake(currentLat, currentLong) let mapItem = MKMapItem(placemark: MKPlacemark(coordinate: coordinate, addressDictionary:nil)) mapItem.name = “Destination/Target Address or Name” mapItem.openInMapsWithLaunchOptions([MKLaunchOptionsDirectionsModeKey : MKLaunchOptionsDirectionsModeDriving]) 

尝试使用

 NSURL(string:"http://maps.apple.com/?saddr=\(currentLat),\(currentLong)&daddr=\(destinationLat),\(destinationLong)")! 

currentLat currentLong是用户当前位置,destinationLat destinationLong是目标位置。

更多的参数(例如:运输types)在这里看看