【问题标题】:swift get directions in maps app在地图应用程序中快速获取路线
【发布时间】:2015-04-17 07:43:37
【问题描述】:

我有一个应用程序可以在多个地图视图中显示多个位置。如何添加一个按钮,允许用户在他们的地图应用程序中打开这些位置之一并获取到它的路线?

【问题讨论】:

    标签: swift maps directions


    【解决方案1】:

    如果您有MKPlaceMark,您可以使用MKMapItem 并打开位置为launchOption 的地图应用程序:

    var mapItem = MKMapItem(placemark: yourPlaceMark)
    
    mapItem.name = "The way I want to go"
    
    //You could also choose: MKLaunchOptionsDirectionsModeWalking
    var launchOptions = [MKLaunchOptionsDirectionsModeKey : MKLaunchOptionsDirectionsModeDriving]
    
    mapItem.openInMapsWithLaunchOptions(launchOptions)
    

    斯威夫特 3

    mapItem.openInMaps(launchOptions: launchOptions)
    

    【讨论】:

    • 对不起,我是新手... :)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-03-22
    • 1970-01-01
    • 2016-03-03
    • 2017-04-27
    相关资源
    最近更新 更多