mkcoordinateregionmakewithdistance Не устанавливает правильный регион на mapView

У меня есть этот код:

- (void)viewDidLoad
{
    [super viewDidLoad];

    CLLocationCoordinate2D userLocation = CLLocationCoordinate2DMake(48.9793946200, 2.4726272850);
    CLLocationDistance dist1 = 636.9887048804;
    CLLocationDistance dist2 = 900.8380655203;
    CLLocationDistance dist = dist1;

    [self.myMapView setRegion:MKCoordinateRegionMakeWithDistance(userLocation, dist, dist) animated:YES];

    // TEST
    // ------------------------------------------------------------
    MKCoordinateRegion region = self.myMapView.region;
    CLLocationDegrees lat = region.center.latitude;
    CLLocationDegrees lon = region.center.longitude - region.span.longitudeDelta/2;
    CLLocation *west = [[[CLLocation alloc] initWithLatitude:lat longitude:lon] autorelease];

    NSLog(@"User location: lat : %.10lf long : %.10lf", userLocation.latitude, userLocation.longitude);
    NSLog(@"distance set: %.10lfm", dist);
    NSLog(@"center: lat : %.8lf long : %.8lf", region.center.latitude, region.center.longitude);

    CLLocation* centerRegion = [[[CLLocation alloc] initWithLatitude:region.center.latitude longitude:region.center.longitude] autorelease];
    NSLog(@"distance to western boundary: %.2lfm", [centerRegion distanceFromLocation:west]);

    lat = region.center.latitude - region.span.latitudeDelta/2 ;
    lon = region.center.longitude;
    CLLocation *north = [[[CLLocation alloc] initWithLatitude:lat longitude:lon] autorelease];

    NSLog(@"distance to western boundary: %.2lfm", [centerRegion distanceFromLocation:north]);
    // ------------------------------------------------------------
}

при настройке dist = dist1, который дает:

User location: lat : 48.9793946200 long : 2.4726272850
distance set: 636.9887048804m

center: lat : 48.97937199 long : 2.47269630
distance to western boundary: 500.44m
distance to western boundary: 650.57m

enter image description here

при настройке dist = dist2, что дает:

User location: lat : 48.9793946200 long : 2.4726272850
distance set: 900.8380655203m

center: lat : 48.97937199 long : 2.47269630
distance to western boundary: 500.44m
distance to western boundary: 650.57m

enter image description here

в чем проблема здесь? Почему у меня есть тот же дисплей с 2 ​​различными расстояниями?

Окончательный вопрос: как я могу показать необходимые меры на карте, как минимум для горизонтальных и вертикальных визуальных (с анимацией или без)?

6
задан nevan king 8 February 2013 в 17:33
поделиться