0
votes

Hi have MKMapView and I make it to zoom depending on the annotations added to mapview, but sometimes I see map zoomed to some level in which annotations fall on the edges and half visible. Below is the code i'm using to set the map region.

MKPolygon *poly = [MKPolygon polygonWithCoordinates:points count:annotationCount]; MKCoordinateRegion region=MKCoordinateRegionForMapRect([poly boundingMapRect]);

Please provide some solution, Thanks.

1

1 Answers

1
votes

So your region is too small, have you considered making it bigger?

Your MKCoordinateRegion has a CLLocationCoordinate2D (center) and a MKCoordinateSpan (span). That MKCoordinateSpan has a latitudeDelta (consider this the height) and a longitudeDelta (consider this the width). What you want to do is a make a slightly larger region. So my first guess is

region.span.latitudeDelta = region.span.latitudeDelta * 1.01;

Then set your mapview to that region