I have an application that provides the user with a scalable MKMapView. I want to be able to save my preferred user coordinates and zoom level if the map view is displayed first.
Currently, in viewDidLoad, I am providing a default set of coordinates and a zoom level for the initial presentation of the map:
zoomLocation.latitude = 55.50;
zoomLocation.longitude = -5.50;
MKCoordinateRegion viewRegion = MKCoordinateRegionMakeWithDistance(zoomLocation, 340.0*METERS_PER_MILE, 340.0*METERS_PER_MILE);
MKCoordinateRegion adjustedRegion = [mapView regionThatFits:viewRegion];
[mapView setRegion:adjustedRegion animated:YES];
What I'm trying to do is when the user scrolls and scales the map to the preferred default view, they can click the "Set as default" button and save the necessary properties that will be implemented in the future when the view is loaded.
To save the coordinates of the user selected view, I have the following:
CGPoint pointCentrePoint = CGPointMake(mapView.frame.size.width/2, mapView.frame.size.height/2);
centrePoint = [mapView convertPoint:pointCentrePoint toCoordinateFromView:mapView];
NSLog(@"LAT: %f LON: %f", centrePoint.latitude, centrePoint.longitude);
, , - MKCoordinateRegion . , ?