ios - 苹果 map 和 MapKit 使用相同的 API 吗?

标签 ios swift mapkit

当我在 Apple map 和我的应用程序中使用 MapKit 进行搜索时,我得到了两个不同的“纽约”结果。

他们都使用相同的 api 吗?

如果我在苹果 map 中搜索“纽约”,它会将指针置于纽约市中心。但是,如果我使用 MKLocalSearchRequestnaturalLanguageQuery 使用 MapKit 搜索“New York”,它会使指针稍微偏离一点,甚至在曼哈顿也不行。

代码:

override func viewDidLoad() {
        super.viewDidLoad()

        self.mapView.delegate = self


        localSearchRequest = MKLocalSearchRequest()
        localSearchRequest.naturalLanguageQuery = "New York"
        localSearch = MKLocalSearch(request: localSearchRequest)
        localSearch.startWithCompletionHandler { (localSearchResponse, error) -> Void in



            if localSearchResponse == nil || self.mapView == nil{
                var alert = UIAlertView(title: "Not found", message: "Try again", delegate: self, cancelButtonTitle: "OK")
                alert.show()
                return
            } else {

                let location = CLLocationCoordinate2D(latitude: localSearchResponse.boundingRegion.center.latitude, longitude:     localSearchResponse.boundingRegion.center.longitude)


                let span = MKCoordinateSpanMake(0.05, 0.05)
                let region = MKCoordinateRegion(center: location, span: span)
                self.mapView.setRegion(region, animated: false)


                self.pointAnnotation = MKPointAnnotation()
                self.pointAnnotation.coordinate = location
                self.mapView.addAnnotation(self.pointAnnotation)
            }


        }

    }

最佳答案

他们不使用相同的 API 进行显示,所以我也假设他们不使用公共(public) API 进行搜索。

特别是考虑到应用程序早于 API 出现

但这可能不是重点

您没有设置区域属性:“提供搜索位置提示的 map 区域。” (至少它看起来与苹果 map 中的不一样)

对我来说它也只返回一个结果[使用 mapkit]

关于ios - 苹果 map 和 MapKit 使用相同的 API 吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31676418/

相关文章:

iOS 错误消息 : reason: '-[__NSArrayM length]:

arrays - Swift 中的数组语法

swift - 根据@State属性设置变量

ios - SpriteKit : node Y position and touch Y position not consistent

swift - Swift-在MKCircle中设置多个fillColor

ios - MKMapView addAnnotations 崩溃

iphone - Mapkit 绘制一个圆

ios - 以随机顺序从字典返回键/元素的最短代码是什么?

ios - 在 iPad 应用程序中禁用 UIImageView 的手势识别器

iphone - 图像在 iOS 中用手指在屏幕上移动