2016-05-18 40 views
1

我正在构建一个以企业及其位置(坐标形式的位置)为特色的应用程序,并且我想提供一个按钮,当按下该按钮时,将用户推送到Apple地图并提出驾驶指示。功能打开苹果地图的驾驶方向?

我该怎么去做这件事?我在StackOverflow上看到过类似的问题,但他们一直指的是移动网页URL,我的应用程序是原生的。

谢谢!

回答

0

是的,你可以做到这一点。看看这个代码。

let placemark : MKPlacemark = MKPlacemark(coordinate: <your coordinate>, addressDictionary:nil) 
    //your placemark... Put in the coordinate here 
    let mapItem:MKMapItem = MKMapItem(placemark: placemark) 
    let launchOptions: NSDictionary = NSDictionary(object: MKLaunchOptionsDirectionsModeWalking, forKey: MKLaunchOptionsDirectionsModeKey) 
    //in the lauch options, you can make it driving, walking, or public transportation 
    MKMapItem.openMapsWithItems([currentLocationMapItem, mapItem], launchOptions: launchOptions as? [String : AnyObject]) 
相关问题