i am adding MKCircleView
to the user annotation like so :
- (void)mapView:(MKMapView *)mapView didUpdateUserLocation:(MKUserLocation *)userLocation
{
if (!_MapCentered) {
**_circle = [MKCircle circleWithCenterCoordinate:userLocation.coordinate radius:3000];
[_map_view addOverlay:_circle];**
_MapCentered = YES;
}
}
it will fire once and once the user location has traced, it works well but as you can see the diameter of the circle view is 3000 meters. so now i want the zoom level to fit the CircleView
like so :
MKCoordinateRegion viewRegion = MKCoordinateRegionMakeWithDistance(mapView.userLocation.coordinate, 0.270, 0.270);
[_map_view setRegion:viewRegion animated:YES];
i have changed the delta degrees to other numbers but nothing is changed. how can i manage this?
For Google's zoom level i use this category for
MKMapView
Otherwise use Anna's solution
The distance parameters in the
MKCoordinateRegionMakeWithDistance
function are in meters (not degrees).Also, the meters specify the full width and height so you have to use double the value of the circle's radius.
So it should be:
You could also just set the map view's
visibleMapRect
to theboundingMapRect
of the circle overlay so you don't have to repeat the distance values:You need to set your span. so set your span value in longitudeDelta & latitudeDelta