我有经度和经度,我想打开我的地图应用程序.我从这里试过这段代码.
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)
}
Run Code Online (Sandbox Code Playgroud)
此功能可以成功打开地图,但不会显示任何图钉.它还显示了我不想要的用户位置.我只想在地图上找到所提供纬度和经度的图钉.