MKCoordinateRegionMakeWithDistance ne définit pas la bonne région sur la MapView

J'ai ce code :

- (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]);
    //------------------------------------------------------------
}

Lorsque le paramètre dist = dist1, ce qui donne :

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

MKCoordinateRegionMakeWithDistance ne définit pas la bonne région sur la MapView

Lorsque le paramètre dist = dist2, ce qui donne :

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

MKCoordinateRegionMakeWithDistance ne définit pas la bonne région sur la MapView

Quel est le problème ici ? Pourquoi dois-je avoir le même affichage avec 2 différentes distances ?

Dernière question : Comment puis-je être sûr pour afficher le voulait mètres sur la carte, à tout le moins à l'horizontale et à la verticale visuelle (avec ou sans animation, bien entendu) ?

Comment êtes-vous en paramètre les coordonnées de la région?
ok, me voir edit 🙂

OriginalL'auteur Oliver | 2011-09-04