最佳答案
I have latitude and longitude that I want to open into my map application. I tried this code from HERE.
func goToMap(){
var lat1 : NSString = self.venueLat
var lng1 : NSString = self.venueLng
var latitude:CLLocationDegrees = lat1.doubleValue
var longitude:CLLocationDegrees = lng1.doubleValue
var coordinate = CLLocationCoordinate2DMake(latitude, longitude)
var placemark : MKPlacemark = MKPlacemark(coordinate: coordinate, addressDictionary:nil)
var mapItem:MKMapItem = MKMapItem(placemark: placemark)
mapItem.name = "Target location"
let launchOptions:NSDictionary = NSDictionary(object: MKLaunchOptionsDirectionsModeDriving, forKey: MKLaunchOptionsDirectionsModeKey)
var currentLocationMapItem:MKMapItem = MKMapItem.mapItemForCurrentLocation()
MKMapItem.openMapsWithItems([currentLocationMapItem, mapItem], launchOptions: launchOptions)
}
This function successfully open maps but it doesn't show any pin. Also it shows user location which I don't want. I only want a pin on the map for the provided latitude and longitude.