在地图应用中快速获取路线 [英] swift get directions in maps app
本文介绍了在地图应用中快速获取路线的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个可以在多个地图视图中显示多个位置的应用程序.如何添加允许用户在其地图应用中打开这些位置之一并获取路线指示的按钮?
I have an app that displays multiple locations in multiple mapviews. How can I add a button that allows the user to open one of these locations in their maps app and to get directions to it?
推荐答案
如果您获得了 MKPlaceMark
,则可以使用 MKMapItem
并打开具有该位置的Map-app作为 launchOption
:
If you got an MKPlaceMark
you can use an MKMapItem
and open the Map-app with the location as 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)
这篇关于在地图应用中快速获取路线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文