2015-07-28 30 views
3

當我使用MapKit在Apple地圖和我的應用程序中進行搜索時,我得到了兩個不同的「紐約」結果。蘋果地圖和MapKit使用相同的API嗎?

它們是否都使用相同的api?

如果我在蘋果地圖上搜索「紐約」,它會將指針放在紐約市中心。但是,如果我使用MKLocalSearchRequestnaturalLanguageQuery搜索「紐約」,它會將指針放在一個位置,即使在曼哈頓也是如此。

代碼:

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) 
      } 


     } 

    } 
+1

你顯然問錯了問題。你需要顯示你使用的代碼來產生對你來說不夠準確的結果,然後可能會問你如何使它更加準確。 – nhgrif

+0

@nhgrif用代碼更新我的問題 –

回答

1

他們不使用用於顯示所以我還以爲他們不使用公共API搜索相同的API。

尤其是考慮到應用早於API

來到但那可能除了點的事實

您沒有設置區域屬性:「提供一個提示,其中A區地圖尋找。」 (至少它是不一樣的蘋果地圖似乎)

對我來說,只返回一個結果,以及[使用mapkit]

相關問題