0
votes

I am making a golf app that should be capable of zooming right up to the green of a hole. Unfortunately I am using Apple's MapKit for this. On certain courses, when attempting to setRegion using the center coordinate and bounds of the green, the app does not zoom all the way into the hole, and if I try again directly afterwards it zooms in a little bit more but not all the way, as if it has trouble zooming into regions where the satellite imagery isn't fully loaded.

There are a number of mentions of issues similar to this one on stack overflow, but no actual solutions. It seems like Apple's MapKit is just useless for displaying small regions, i.e. less than ~100 meters. The infuriating thing is I can easily zoom into smaller regions using the normal pinch-zoom behavior, but if I attempt to setRegion into exactly the same zoom level it only zooms in about half way.

I have wasted so much time trying to solve this problem I have considered just switching my entire map to google's map view library.

My project is in Swift 2.2 but I have experienced exactly the same issue in a separate project using Objective-C. My Swift code looks like this:

    let holeBounds: CGRect = courseSingleton!.findGreenBounds(statsSingleton!.hole)
    let center = CLLocationCoordinate2DMake(Double(holeBounds.origin.y + holeBounds.size.height/2), Double(holeBounds.origin.x + holeBounds.size.width/2));

    let coordinateRegion = MKCoordinateRegionMake(center, MKCoordinateSpanMake(Double(holeBounds.size.height), Double(holeBounds.size.width)))

    mapView.setRegion(coordinateRegion, animated: false)
1

1 Answers

0
votes
 let address : CLLocationCoordinate2D = self.getLocation(String(txtSearchlocation.text))
 let region = MKCoordinateRegionMakeWithDistance(address, 0.05, 0.05)
 MapView.setRegion(region, animated: true)

i think you should try this one for zoom..