gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-29 11:46:54 26 4
gpt4 key购买 nike

注释添加到您的应用程序中的 MapKit View 非常容易。

theMap: MKMapView!

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

但是你到底是怎么让 map 应用添加注释的呢??

这是打开 map 应用程序到特定地址的具体方法..

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 传递给实际的 map 应用程序的呢??

(同样 - 在您自己的应用程序内的 map View 上添加 MKPointAnnotation 很容易。)

有什么想法吗?真的可以吗??

最佳答案

我认为 openInMaps 仅将您限制为 the five possible launch options .但是我想知道你是否可以让Apple Maps以原始方式打开,openURL和maps.apple.com/maps,如this SO question所示。 .但是,对于最新的 iOS 版本,您似乎还需要在“URL 类型 ... URL 方案”或“LSApplicationQueriesSchemes”下的 info.plist 中注册您正在使用的 URL。您可以将注释作为参数与 URL 一起传递。

关于ios - 如何让 Apple Maps App(不是 MapKit)添加注释?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43234808/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com