Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS - MKMapView showAnnotations:animated: with padding?

I want to be able to zoom my MKMapView to fit it's annotations. I have managed to do it using iOS7's showAnnotations method. But I would also like to add some padding or inset from the map view border. This is because I have a semi-transperant view that overlays the top part of my map, and I don't want annotations to be places behind this view. I have tried this:

[self.mapView showAnnotations:annotations animated:YES];
[self.mapView setVisibleMapRect:self.mapView.visibleMapRect edgePadding:UIEdgeInsetsMake(100, 20, 10, 10) animated:NO];

But it's not working as I would have hoped. Any ideas on how I could do it differently?

like image 957
Anders Avatar asked Feb 20 '14 15:02

Anders


1 Answers

You could also simply use

[self.mapView showAnnotations:annotations animated:YES];
self.mapView.camera.altitude *= 1.4;

to zoom out a little. Works well for me.

like image 189
gorkem Avatar answered Oct 08 '22 22:10

gorkem