How to keep current MKCoordinateRegion or scaling level?

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;

    // specify size of region to display
    MKCoordinateRegion viewRegion = MKCoordinateRegionMakeWithDistance(zoomLocation, 340.0*METERS_PER_MILE, 340.0*METERS_PER_MILE);

    // auto adjust region to fit screen
    MKCoordinateRegion adjustedRegion = [mapView regionThatFits:viewRegion];                

    // display the new region
    [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:

// gets coordinates of currently viewed map image
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 . , ?

+3
1

JavaScript Google Maps api, MKMapView " " ( ).

.

, / NSUserDefaults.

+2

All Articles