Quick route search in the map application

I have an application that displays multiple locations on multiple maps. How can I add a button that allows the user to open one of these places in my map application and get directions to it?

+5
source share
1 answer

If you received MKPlaceMark , you can use MKMapItem and open a Map application with the launchOption location:

 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) 

Swift 3

 mapItem.openInMaps(launchOptions: launchOptions) 
+23
source

Source: https://habr.com/ru/post/1213481/


All Articles