Question

I have some annotations presented on a map (somepoints) the map zooms in or out to fit all points - see working code below.

MKPolygon *poly = [MKPolygon polygonWithPoints:somepoints count:i];
[self.mapView setRegion:MKCoordinateRegionForMapRect([poly boundingMapRect]) animated:NO];

Q: I would like to expand this poly just slightly to have some margins, how can I enlarge this Region?

Was it helpful?

Solution

You can increase the span of the region in order to add some margin:

MKCoordinateRegion region = MKCoordinateRegionForMapRect([poly boundingMapRect]);
region.span.latitudeDelta *= 1.2;   // Increase span by 20% to add some margin
region.span.longitudeDelta *= 1.2;
[self.mapView setRegion:region animated:YES];
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top