Monday, September 22, 2014

MKMapItem - openMapsWithItems - from current location to another location


coordinate -> placemark -> mapitem -> array of mapitems -> openMapsWithItems



****
import MapKit

****

let currentLocation = MKMapItem.mapItemForCurrentLocation()
        
let markTaipei = MKPlacemark(coordinate: CLLocationCoordinate2DMake(25.0305, 121.5360), addressDictionary: nil)
        
let taipei = MKMapItem(placemark: markTaipei)
        
taipei.name = "Taipei Daan Park"
        
let array = NSArray(objects: currentLocation, taipei)
        
let parameter = NSDictionary(object: MKLaunchOptionsDirectionsModeDriving, forKey: MKLaunchOptionsDirectionsModeKey)
        

MKMapItem.openMapsWithItems(array, launchOptions: parameter)

No comments:

Post a Comment