When I do a search in the Apple maps and one in my app using MapKit I get two different results for "New York".
Do they both use the same api?
If I do a search for "New York" in apple maps it will place the pointer in the center of NY city. But if I do a search for "New York" with MapKit using MKLocalSearchRequest and naturalLanguageQuery it will place the pointer a bit off, not even in Manhattan.
code:
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)
}
}
}
they don't use the same api for displaying so I'd also assume they don't use the public API for searching.
Especially given the fact that the app came earlier than the API
You don't set the region property: "A map region that provides a hint as to where to search." (at least it isn't the same as in apple maps it seems)
for me it returns only ONE result as well [using mapkit]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With