Convert MKMapRect to CGRect
Asked Answered
G

1

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];
Goldengoldenberg answered 26/2, 2014 at 21:10 Comment(0)
N
8

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.

Nies answered 27/2, 2014 at 2:18 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.