I want to determine if a user has scrolled more than a certain percentage of the map then disable centering of the map from the user location (similar to how the Maps app works).
I’m not sure which methods to make use of.
I think it would be straightforward to create a rectangle and see if the rectangle contains the current center point, however I have to target IOS 3, so I can’t make use of many of the newer Mapkit apis.
I’ve tried futzing with CLLocation, and using distanceFrom, between the current mapcenter, and the users location, but I’m trying to figure out if that distance is a certain percentage.
I personally find it more helpful when someone can post a snippet of code versus general prose about how one might go about this. Here’s what I came up with- roughly hacked out to simply better answer this question:
In a header file I have:
and in my view (that is both a delegate for CLLocationManagerDelegate, MKMapViewDelegate):
Hope that sends you in the right direction.
distanceFromLocation is iOS 3.2 and later.
initWithLatitude is iOS 2.0 and later.
MKCoordinateRegion is iOS 3.0 and later.
MKMapView centerCoordinate is iOS 3.0 and later.
Also- please feel free to jump in and set me straight where I’ve erred. I’m figuring all of this out myself- but this is working fairly well for me so far.
Hope this helps someone.