De retour MapKit Userlocation Coordonnées

voix
1

chaque fois que j'essaie de retourner les coordonnées lat / long pour mon emplacement actuel, mon application se bloque sans explication de l'erreur ...

NSLog(@%@, mapView.userLocation.location.coordinate);

J'attends jusqu'à ce que le téléphone trouve l'emplacement et ...

Créé 30/10/2009 à 21:58
source utilisateur
Dans d'autres langues...                            


2 réponses

voix
5

mapView.userLocation.location.coordinateest un struct alors que le %@spécificateur de format attend un objet. Cela fonctionne:

NSLog(@"%f, %f", mapView.userLocation.location.coordinate.latitude,
                 mapView.userLocation.location.coordinate.longitude);
Créé 30/10/2009 à 22:02
source utilisateur

voix
0

Pour une raison quelconque, cela ne fonctionne pas pour moi. Il me prend aux coordonnées (0,0000, 0,0000). Ci-dessous mon code si vous avez une chance de le vérifier. Merci pour l'aide!

[mapView setMapType:MKMapTypeStandard];
    [mapView setZoomEnabled:YES];
    [mapView setScrollEnabled:YES];
    mapView.showsUserLocation=TRUE;

    MKCoordinateRegion region = { {0.0, 0.0 }, { 0.0, 0.0 } };

    CLLocationCoordinate2D myCoord = {mapView.userLocation.location.coordinate.latitude,mapView.userLocation.location.coordinate.longitude};
    [mapView setCenterCoordinate:myCoord animated:YES];

    region.span.longitudeDelta = 0.01f;
    region.span.latitudeDelta = 0.01f;
    [mapView setRegion:region animated:YES]; 

    [mapView setDelegate:self];
Créé 20/12/2010 à 23:57
source utilisateur

Cookies help us deliver our services. By using our services, you agree to our use of cookies. Learn more