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

How to get Apple Maps App (not MapKit) to add an annotation?

注释添加到在您的应用程序内的 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 仅将您限制为 the five possible launch options. But I wonder if you could get Apple Maps to open in the original way, openURL and maps.apple.com/maps, as shown in this SO question。但是,对于最新的 iOS 版本,您似乎还需要在 "URL Types ... URL Schemes" 或 "LSApplicationQueriesSchemes" 下注册您在 info.plist 中使用的 URL。您可以使用 URL.

将注释作为参数传递