Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does apple maps and MapKit use the same API?

Tags:

ios

swift

mapkit

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


        }

    }
like image 939
Kiwo Tew Avatar asked Feb 28 '26 01:02

Kiwo Tew


1 Answers

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

BUT thats likely besides the point

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]

like image 102
Daij-Djan Avatar answered Mar 02 '26 14:03

Daij-Djan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!