如何让Apple Maps App(不是MapKit)添加注释?

注释添加到应用程序内的MapKit视图中非常容易。

theMap: MKMapView! let pa = MKPointAnnotation() pa.title = "title!!" etc theMap.addAnnotation(pa) 

但是你如何使地图应用程序添加注释?

这里是如何打开地图应用程序到某个地址..

 func appleMapApp() { quickAddressText = "123 Smith St 90210" let bottomText = "This shows at BOTTOM Of Maps App screen." let g = CLGeocoder() g.geocodeAddressString(quickAddressText) { placemarks, error in if let found = placemarks?.first, let lok = found.location { let p = MKPlacemark(coordinate: lok.coordinate, addressDictionary: nil) let mapItem = MKMapItem(placemark: p) mapItem.name = bottomText mapItem.openInMaps(launchOptions: showing(location: lok)) } } } // convenient function... func showing(location: CLLocation, meters m: CLLocationDistance = 1000)->[String : Any]? { let cr = MKCoordinateRegionMakeWithDistance(location.coordinate, m,m) let options = [ MKLaunchOptionsMapCenterKey: NSValue(mkCoordinate: cr.center), MKLaunchOptionsMapSpanKey: NSValue(mkCoordinateSpan: cr.span) ] return options } 

这很棒 – 但是你如何将MKPointAnnotation传递给实际的地图应用程序?

(再次 – 在您自己的应用程序内的地图视图中添加MKPointAnnotation很容易。)

有任何想法吗? 它真的可能吗?

我认为openInMaps仅限于五个可能的启动选项 。 但我想知道你是否可以以原始方式打开Apple Maps,openURL和maps.apple.com/maps,如本SO问题所示。 但是,对于最新的iOS版本,您似乎还需要在“URL类型… URL方案”或“LSApplicationQueriesSchemes”下的info.plist中注册您正在使用的URL。 您可以使用URL将注释作为参数传递。