Reputation: 11
I have the first point in center of MKMapView
and distance in meters to map's left border that the center should be.
How do I set the region for that?
Upvotes: 0
Views: 1494
Reputation:
Given the center coordinate and the distance in meters from the center to the border, you can use the MKCoordinateRegionMakeWithDistance
function to create the region:
CLLocationCoordinate2D centerCoord = CLLocationCoordinate2DMake(lat, lng);
CLLocationDistance centerToBorderMeters = 5000;
MKCoordinateRegion rgn = MKCoordinateRegionMakeWithDistance
(centerCoord,
centerToBorderMeters * 2, //vertical span
centerToBorderMeters * 2); //horizontal span
[mapView setRegion:rgn animated:YES];
Upvotes: 1