Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the difference between MKMapRect and MKCoordinateRegion

They both specify a map center and how big the box is.

So why use both?

Some function in MKMapview use one and some use the other

  • (MKCoordinateRegion)regionThatFits:(MKCoordinateRegion)region
  • (MKMapRect)mapRectThatFits:(MKMapRect)mapRect edgePadding:(UIEdgeInsets)insets

What's their difference?

More importantly, which one we should use to set the region we see?

There is no regionThatFits:edgePadding: by the way.

like image 713
user4951 Avatar asked Aug 15 '12 03:08

user4951


1 Answers

A MKCoordinateRegion is defined using degrees coordinate of type CLLocationCoordinate2D which represents the latitude and longitude of a point on the surface of the globe.

MKMapRect represents an actual flat rectangle defined with view coordinate (x, y) on your map view.

You can use functions to do conversions for you like MKCoordinateRegionForMapRect

See http://developer.apple.com/library/ios/#documentation/MapKit/Reference/MapKitFunctionsReference/Reference/reference.html

And to answer your final question, you would use MKCoordinateRegion which will define what region of the globe's surface you want to see and by definition it will set your zoom level.

like image 161
Sylvain Guillopé Avatar answered Oct 18 '22 13:10

Sylvain Guillopé