1

I generally have no problem placing annotations on my MKMapView. 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:

This is how it looks when I first load the MKMapView:


(source: grapekeeper.com)

When I pan I can see more pins that are lost on that original view:


(source: grapekeeper.com)

And when I pinch in the simulator this is as zoomed out as it goes:


(source: grapekeeper.com)

Here's my code for reference:

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];
Glorfindel
  • 21,988
  • 13
  • 81
  • 109
lemontwist
  • 301
  • 11
  • 26
  • By the way I also have tried setting `overallRegion.span.latitudeDelta = 180` and `overallRegion.span.longitudeDelta = 360` with the same result. – lemontwist Aug 15 '12 at 20:22
  • What are the dimensions of the map view? What happens if you make it full screen? –  Aug 15 '12 at 23:34
  • @AnnaKarenina, 300x300 pixels, I tried changing the size & aspect ratio with no luck. I also tried using aspect fit to see if it would help and it made no difference. – lemontwist Aug 15 '12 at 23:35

2 Answers2

2

The answer is: it's not possible to zoom out enough to view the entire world using the map view.

lemontwist
  • 301
  • 11
  • 26
1

looks like just adding a little bit extra space and considering diagonals would help, see What's the best way to zoom out and fit all annotations in MapKit

which gives a nice method for doing exactly what you want.

Community
  • 1
  • 1
timofei7
  • 341
  • 2
  • 4
  • 1
    Didn't help. Still doesn't zoom out enough to show everything. I can't even manually pinch/zoom out enough. – lemontwist Aug 15 '12 at 23:17
  • oh! interesting just tried it myself in my app and can't pinch out to see the whole world either. I think the problem is that there is no zoom level that can show the whole world map! weird, now I'm intrigued. http://stackoverflow.com/questions/4973645/mapkit-show-entire-globe seems to suggest its not possible. – timofei7 Aug 15 '12 at 23:42
  • yeah it's really bizarre. I mean it's not a huge deal but I'm kind of anal so I'd like to see all the pins at once. Of course I'm sure this will all change once iOS6 comes out... – lemontwist Aug 15 '12 at 23:44
  • so turns out just in the Maps app you can't zoom out to see whole world either! My guess is that the smallest tile size google provides is bigger than the screen resolution. One way to get around it might be to make a bigger mapview and then convert it to a uiimage (saw some threads about doing that) and display that scaled down. Probably would have to do something special to capture any gestures/input though. – timofei7 Aug 16 '12 at 00:16