Note that there are some explanatory texts on larger screens.

plurals
  1. POWhy isn't my MKMapView zooming out as much as it should?
    text
    copied!<p>I generally have no problem placing annotations on my <code>MKMapView</code>. I have pins for various locations and the code automatically centers and sets the span based on the max and min values. However, I am noticing that when I add more and more points, there is a certain amount my map will zoom out to see, and I lose what is on the edges. Here are some pics:</p> <p>This is how it looks when I first load the MKMapView:</p> <p><a href="http://www.grapekeeper.com/tempcrap/start.png" rel="nofollow noreferrer">http://www.grapekeeper.com/tempcrap/start.png</a></p> <p>When I pan I can see more pins that are lost on that original view:</p> <p><a href="http://www.grapekeeper.com/tempcrap/start-move.png" rel="nofollow noreferrer">http://www.grapekeeper.com/tempcrap/start-move.png</a> <a href="http://www.grapekeeper.com/tempcrap/start-pan.png" rel="nofollow noreferrer">http://www.grapekeeper.com/tempcrap/start-pan.png</a></p> <p>And when I pinch in the simulator this is as zoomed out as it goes:</p> <p><a href="http://www.grapekeeper.com/tempcrap/pinch-zoom-out.png" rel="nofollow noreferrer">http://www.grapekeeper.com/tempcrap/pinch-zoom-out.png</a></p> <p>Here's my code for reference:</p> <pre><code>double min = [[allLatitudes valueForKeyPath:@"@min.self"] doubleValue]; double max = [[allLatitudes valueForKeyPath:@"@max.self"] doubleValue]; double latSpan = max-min; double minL = [[allLongitudes valueForKeyPath:@"@min.self"] doubleValue]; double maxL = [[allLongitudes valueForKeyPath:@"@max.self"] doubleValue]; double lonSpan = maxL-minL; double avgLatitude = (max+min)/2; double avgLongitude = (maxL+minL)/2; overallRegion.center.latitude = avgLatitude; overallRegion.center.longitude = avgLongitude; overallRegion.span.latitudeDelta = latSpan; overallRegion.span.longitudeDelta = lonSpan; [self.mapView setRegion:overallRegion animated:YES]; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload