【问题标题】:Function to open apple maps for driving directions?打开苹果地图的行车路线功能?
【发布时间】:2016-05-18 04:21:59
【问题描述】:

我正在构建一个应用程序,其中包含企业及其位置列表(坐标形式的位置),并且我想提供一个按钮,当按下该按钮时,将用户推送到 Apple 地图并显示行车路线.

我该怎么做呢?我在 StackOverflow 上看到过类似的问题,但他们指的是移动 Web URL,我的将是应用程序的原生 URL。

谢谢!

【问题讨论】:

    标签: swift maps directions


    【解决方案1】:

    是的,您可以这样做。查看此代码。

        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])
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-06-22
      • 1970-01-01
      • 2012-05-17
      • 1970-01-01
      • 1970-01-01
      • 2013-03-11
      相关资源
      最近更新 更多