6

I'm trying to find out the size of an MKMapRect in points (i.e. 320x568 points for iPhone).

Is there something similar to converting co-ordinates to points? i.e.

[self.mapView convertCoordinate:coordinate1 toPointToView:self.view];
NMunro
  • 1,282
  • 4
  • 18
  • 33

1 Answers1

7

The map view has the convertRegion:toRectToView: method which takes an MKCoordinateRegion and converts it to a CGRect relative to the specified view.

If you have an MKMapRect, first convert it to an MKCoordinateRegion using the MKCoordinateRegionForMapRect function and then call convertRegion:toRectToView:.

Example:

MKCoordinateRegion mkcr = MKCoordinateRegionForMapRect(someMKMapRect);

CGRect cgr = [mapView convertRegion:mkcr toRectToView:self.view];


Remember that although the MKMapRect for some fixed area will not change as the map is zoomed or panned, the corresponding CGRect will vary in its origin and size.